framework icon indicating copy to clipboard operation
framework copied to clipboard

Hash links do not work correctly when using the `StateHistory` manager

Open agubler opened this issue 6 years ago • 1 comments

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.

  1. When working with lazily loaded content (for example when an application is leveraging code splitting), the router or native a node with a href updates the hash before the content with the matching id has been rendered. This means that the browser will not navigate to the correct section of content.

  2. The Link components have no way to accept an additional hash. A native a node can be used but the user would need to generate the correct route prefix using the router.link command. 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 avatar Mar 01 '19 13:03 agubler

@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

matt-gadd avatar Mar 01 '19 13:03 matt-gadd