The page title in the browser history is wrong when navigating to some pages #311
-
When navigating to some of the pages in my Solid SPA, with SolidRouter, the title saved to the browser history is wrong. Instead of the title for the previous page, it shows the title for the new page in the browser history. The actual URL in the history is correct--if I click Back, I go back to the previous route. I set the title via document.title when the page component is loaded, at the top of the main function for the component. The title gets set correctly on the browser tab. This seems to happen because the title is updated to the new value before the router saves the previous page to the history stack. I've verified this by waiting about a half second before updating the title, which eliminates the problem, but leaves me with a creepy title update effect. I've tried using useLocation() and useIsRouting() in an effect to detect when routing is finished, but in both cases these appear to fire before the history entry is saved. Is there some way to know when it's safe to change the page title? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
solid-router 0.13.6 is released now with #442 included. |
Beta Was this translation helpful? Give feedback.
solid-router 0.13.6 is released now with #442 included.
After a route change, when useIsRouting becomes false, you can go ahead and safely update the title.