-
-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Users first navigation on <a>
tag does not update URL if inside <ParentRoute>
without <Outlet />
#3605
Comments
Hi, I took a look at nested_router.rs, and based on my current (albeit naive) understanding, here's what I think is happening: In the implementation of leptos/router/src/nested_router.rs Lines 103 to 109 in d0bf843
Then, it creates the first outlet on its own, assuming that there should eventually be an outlet somewhere: leptos/router/src/nested_router.rs Lines 605 to 617 in d0bf843
During the rebuild phase, it matches the current view's ID with the first view's ID in the stack, which is again the current view because a real outlet was not actually included in the routes: leptos/router/src/nested_router.rs Line 710 in d0bf843
As a result, the condition is never met, and the leptos/router/src/nested_router.rs Lines 758 to 760 in d0bf843
Consequently, later in the implementation, when it waits for the loaders to finish, they never complete, and the notifying never happens: leptos/router/src/nested_router.rs Lines 118 to 124 in d0bf843
If you don't push the outlet at line 617, your problem will be solved. However, I don't think this is the right approach, as it might cause other issues. My suggestion is to add an argument to the |
…rentRoute>` without `<Outlet />` (closes leptos-rs#3605)
I read the additional context but I'm not sure I understand why using an If anyone sees a straightforward fix to this, I'm happy to look at a PR, but to me this otherwise is WAD. |
Describe the bug
Using the example code below, the first navigation of the user is ignored. All subsequent navigations work fine however. Also, the
navigate
function appears to be working fine too. It works if I declare an<Outlet />
component, however, see "Additional Context" for why this is not always desirable.Leptos Dependencies
To Reproduce
Expected behavior
When the user clicks on the link, they should navigate to the page.
Additional context
My Application is largely ignoring leptos-router: I only use the router for the actual routing behavior, but I render all of the components manually based on a
use_location
trigger. I do this because some bits of my application are using a routing scheme that does not fit well into the traditional routing behavior (or nested routing behavior) of a web page. As it is more an App than a pure web page, it has some application states mapped to specific routes. For example, my home route ("/") and my "/search" route are the same page; their only difference is that the user has entered something in the search box presented on the front page, and accordingly, search results are being displayed.Because
use_location
didn't work outside of a route in 0.6 (probably still doesn't in 0.7 although I haven't tested yet), I have my entire application inside theview
on a<ParentRoute>
. The route elements inside of that ParentRoute are allview=|| ()
as all the actual displaying of the content is done by manually parsing the URL in a Memo viause_location()
and then using that information in various components to alter their content.The text was updated successfully, but these errors were encountered: