-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
feature request: pass navigationInstruction to canDeactivate #493
Comments
If the request is accepted I would be happy to work on this |
By all means, please proceed :) Have a look in |
So I tried simply passing the navigationInstruction into the call to canDeactivate as you can see here but at this point in the pipeline calling getAllInstructions() on this navigationInstruction doesn't return all instructions, it only ever returns one even when there are two child routers. Next I tried moving LoadRouteStep in front of CanDeactivateStep in the PipelineProvider (here), and now I get exactly what I need in canDeactivate - three navigationInstructions when there are two child routers. I think LoadRouteStep ends up loading the actual components too though, right? If that's the case this isn't the right approach, and I'm not sure where to go next. Can I get some guidance on this please? |
What editor/extensions do you guys use to build this? VS Code whines that "types can only be used in .ts files", and I'm not sure what I need to install to get support for the type declarations. |
We're not using any editor extensions. Technically, these are Flow types supported by Babel. We're planning to move this all to TS. Regarding the questions above, we don't want to change the order of the steps. |
We don't need this enhancement anymore. Please feel free to close the feature request if no one else is asking for it. Thanks |
This would be useful, the alternative seems a bit hacky... Will look at a PR. |
Made a start, not quite sure where to go from here but passing the |
I'm submitting a feature request
1.3.0
Please tell us about your environment:
Operating System:
Windows 10
Browser:
all
Language:
TypeScript 2.3
Current behavior:
No arguments are passed to canDeactivate, so the requested route cannot be used to determine actions needed to be taken.
Expected/desired behavior:
What is the expected behavior?
Pass the navigationInstruction to canDeactivate so that the requested route can be inspected before taking action.
What is the motivation / use case for changing the behavior?
I want to confirm navigation only if the user requested a route outside of the current parent route. If the user navigates to a sibling route, I want to allow navigation without confirming. The scenario is a wizard, where the user can navigate between pages of the wizard before saving, but shouldn't be able to leave the wizard altogether.
This can be achieved by handling canDeactivate on the parent, but NOT if the activation strategy is "replace" or "invoke-lifecycle", because then canDeactivate is called on the parent when navigating between children too.
The text was updated successfully, but these errors were encountered: