-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Should we implicitly merge params? #2941
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
Comments
Hi @posva! |
See #1572 (comment) |
Sorry to comment on an old issue, but I'm currently migrating to vue-router 4 and it seems this "implicit merge" behavior has been removed? I didn't find any mention of this in the migration guide: https://router.vuejs.org/guide/migration/ Example: we have a The weird part is that it seems to be thrown only when leaving the page (thus breaking the app), meaning that loading the profile page first still works fine 🤷 I'd like to be sure before updating our whole codebase according to this :) I'm not sure it's a bug or a feature, but I can open a new issue if needed. Thanks. |
Facing the same issue. Links with implicit params work, but when navigating away from a page that contains links with implicit params to a page that does not use that param, it throws the "Missing required param" error and all navigation is completely broken in the app. Very strange behavior. |
@nicooprat Did you ever find a solution for this? |
As far as I can remember, we just added the missing params explicitely everywhere… I guess it’s safer this way, but it was a lot of work! |
Yeah... I was hoping that wouldn't be the only option. Oh well, thanks! |
Coming from #2800 (comment)
Right now 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:
/a/2
,{ name: 'b.one' }
will point to/b/2/one
but we are sharing a param across different routes/b/2/two
,{ name: 'b.one' }
will point to/b/2/one
/b/2/two
,{ name: 'b.dyn', params: { dynamic: 'foo' } }
will point to/b/2/foo
, params are partially merged/a/2
,{ name: 'b.dyn', params: { dynamic: 'foo' } }
will point to/b/2/foo
, params are partially merged across routes that are unrelated/a/2/other
,{ name: 'b.dyn' }
will point to/b/2/other
, params are taken from a different routeThis 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
query
and it's very easy to pass explicitly pass params with{ params: {...this.$route.params, ...otherParams} }
and make it easier to guess. In any case, we won't remove current behavior but I need to trace back to where we started doing that and make sure is the right choice for future versionsThe goal of this issue is to discuss about this behavior in order to decide wether to keep it for future versions or not
The text was updated successfully, but these errors were encountered: