Routing: support routing to a specific element ID (e.g. /home#about) and scrolling to the right place #1727
sinking-point
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In plain HTML you can link to a specific ID on a page, e.g.
This navigates to
/home
and scrolls to the element with IDabout
.There appears to be no way to do a similar thing with RouterAnchor. I have tried doing something like this:
However, this doesn't scroll to the specified element. It's also unergonomic.
I don't have a full understanding of how the routing works, but I propose having a method in
Switch
which takes an ID of an element and returns a struct that also implementsSwitch
. The struct would store the ID to scroll to, along with the originalSwitch
-implementing enum value. When aRoute
is generated from theSwitch
, the ID is passed through so that the router knows to scroll to the ID.This would allow syntax like:
Beta Was this translation helpful? Give feedback.
All reactions