framework
framework copied to clipboard
Hash links do not work correctly when using the `StateHistory` manager
Enhancement
When a hash is applied the expected behaviour is the browser to scroll to an associated node with a matching id attribute. There are a couple of issues dealing using anchor tags in combination with using the StateHistory manager.
-
When working with lazily loaded content (for example when an application is leveraging code splitting), the router or native
anode with ahrefupdates the hash before the content with the matchingidhas been rendered. This means that the browser will not navigate to the correct section of content. -
The
Linkcomponents have no way to accept an additional hash. A nativeanode can be used but the user would need to generate the correct route prefix using therouter.linkcommand. Although this would take some boilerplate that should not be necessary.
It could perhaps be possible for the framework manage the hash navigation in some way once lazily loaded content is rendered. This would need some investigation to see how it could be handled/implemented.
For the Link part of issue, perhaps creating a new Link component that provides all the link details but leaves the what to render up to the consumer - this would allow them to add a hash to the router generated url.
@agubler it would be nice to support this with the hash adapter too if possible (even though it would look weird) #foo/bar/baz#element-to-scroll-to