Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect <title> value set for external pattern-library pages #1052

Open
lyzadanger opened this issue May 26, 2023 · 0 comments
Open

Incorrect <title> value set for external pattern-library pages #1052

lyzadanger opened this issue May 26, 2023 · 0 comments
Labels

Comments

@lyzadanger
Copy link
Contributor

For consuming applications that add their own pattern library pages (routes), the HTML <title> element is getting set incorrectly when routing.

The relevant useEffect hook in /src/pattern-library/components/PatternLibraryApp is looking at the wrong set of routes (this array only contains routes defined by the pattern library source):

  // Update document title when `wouter` path changes.
  useEffect(() => {
    const activeRoute = routes.find(({ route }) => route === pathname);
    document.title = `${
      activeRoute?.title ?? 'Page not found'
    }: Hypothesis Component Library`;
  }, [pathname, routes]);

The net result is that page titles on pages added by applications get set to:

Page not found: Hypothesis Component Library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants