-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Dynamic segments for nested items not updating correctly #2800
Dynamic segments for nested items not updating correctly #2800
Comments
I add a simpler reproduction link for it. https://jsfiddle.net/zrh122/3v4cj0qk/ |
Thanks for the smaller reproduction, I updated the original issue to be clearer. The problem here is that the router-link isn't rendering when current route changes, so I don't think #2802 is the right fix. At the same time, we are allowing implicit partial params to the location passed to router-link but this is bug-prone as the router link could be used in a different views that may not even be the parent of the location but still share the same param id and I don't think we should reuse the param in that case. Take the following case: const routes = [
{ path: '/a/:id', name: 'a' },
{ path: '/a/:id/:dynamic', name: 'a.dyn' },
{ path: '/b/:id', name: 'b', children: [
{ path: 'one', name: 'b.one' },
{ path: 'two', name: 'b.two' },
{ path: ':dynamic', name: 'b.dyn' }
]
}
]
This makes me wonder if it's really a good idea to implicitly merge params solely based on their name. We don't do this with |
Yeah, i agree with it and at now merge params is very simple. But look at this https://jsfiddle.net/zrh122/Lu89js0n/ (add some print) to: {
name: 'items.logs.type',
params: { type: 'info' }
}, be changed to: to: {
name: 'items.logs.type',
params: { type: 'info', id: 1 }
}, i think this should not happen. |
Version
3.0.3
Reproduction link
https://jsfiddle.net/zrh122/3v4cj0qk/
Steps to reproduce
What is expected?
We end up at /item/2/logs
What is actually happening?
We end up at /item/1/logs
This behavior happens when we don't explicitly set a parent param for a child route. Setting $route.params.id before rendering the fixes the behavior, but this shouldn't be necessary as we already navigated to /item/2, but vue-router didn't update the dynamic segment.
The text was updated successfully, but these errors were encountered: