Discussed in #416
Originally posted by LeoniePhiline June 7, 2025
Hi!
we‘ve had a bug with NavItem seeming to work unreliably. As it turned out, we had the incorrect expectation that a link-NavItem would act like a Leptos router link <A>. However, NavItem in fact renders as HTML anchor <a>.
One of the behavior differences comes up when using nested <Routes>:
The Leptos router link component resolves the href relative to the parent route, while with the HTML anchor element, the browser uses the existing URL and has no knowledge about routes. This causes different resulting target navigation URLs depending on if the current url does or does not have a trailing slash.
This observation made me consider that maybe NavItem should use <A> in thaw 0.5.
What do you think? Is there any advantage at all in the use of the html anchor element rather than the routes-aware Leptos router component?
Discussed in #416
Originally posted by LeoniePhiline June 7, 2025
Hi!
we‘ve had a bug with
NavItemseeming to work unreliably. As it turned out, we had the incorrect expectation that a link-NavItemwould act like a Leptos router link<A>. However,NavItemin fact renders as HTML anchor<a>.One of the behavior differences comes up when using nested
<Routes>:The Leptos router link component resolves the
hrefrelative to the parent route, while with the HTML anchor element, the browser uses the existing URL and has no knowledge about routes. This causes different resulting target navigation URLs depending on if the current url does or does not have a trailing slash.This observation made me consider that maybe
NavItemshould use<A>in thaw 0.5.What do you think? Is there any advantage at all in the use of the html anchor element rather than the routes-aware Leptos router component?