You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the time of this console.log(), the actual URL in the browser has been visibly updated. And the parameter does make it into currentInstruction eventually. But for some reason, router.currentInstruction does not get updated synchronously. This is causing havoc in my logic when I want to do non-destructive changes like the following:
/** * Apply one or more route params, keeping the current route * and all other param values. */exportfunctionassignRouteParams(router: Router,params: {[key: string]: any}){if(router.currentInstruction!=null){router.navigateToRoute(router.currentInstruction.config.name??"unknown",{ ...router.currentInstruction.params, ...router.currentInstruction.queryParams, ...params},{replace: true});}}
Here, currentInstruction.queryParams cannot be relied upon to include any changes that have just been made to the params via navigateToRoute, which means things get lost.
Is this a bug? And if not, is there a workaround? I tried adding trigger: true to the options, to no effect.
The text was updated successfully, but these errors were encountered:
Workaround for anyone else who's stuck on this bug, pushing the navigation instruction onto the event loop seems to work:
/** * Apply one or more route params, keeping the current route * and all other param values. */exportfunctionassignRouteParams(router: Router,params: {[key: string]: any}){if(router.currentInstruction!=null){setTimeout(()=>router.navigateToRoute(router.currentInstruction.config.name??"unknown",{ ...router.currentInstruction.params, ...router.currentInstruction.queryParams, ...params},{replace: true}),0);}}
At the time of this
console.log()
, the actual URL in the browser has been visibly updated. And the parameter does make it intocurrentInstruction
eventually. But for some reason,router.currentInstruction
does not get updated synchronously. This is causing havoc in my logic when I want to do non-destructive changes like the following:Here,
currentInstruction.queryParams
cannot be relied upon to include any changes that have just been made to the params vianavigateToRoute
, which means things get lost.Is this a bug? And if not, is there a workaround? I tried adding
trigger: true
to the options, to no effect.The text was updated successfully, but these errors were encountered: