Skip to content
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

bug: Navigation Hooks are never called (beforeEnterHook, beforeLeaveHook) #22516

Closed
igorovic opened this issue Nov 18, 2020 · 11 comments · Fixed by #22521
Closed

bug: Navigation Hooks are never called (beforeEnterHook, beforeLeaveHook) #22516

igorovic opened this issue Nov 18, 2020 · 11 comments · Fixed by #22521

Comments

@igorovic
Copy link

Bug Report

Ionic version:
[ ] 4.x
[x] 5.x

Current behavior:
ion-route properties beforeEnter and beforeLeave are removed in function matchesPath

snippet

return chain.map((route, i) => ({
      id: route.id,
      path: route.path,
      params: mergeParams(route.params, allparams![i])
    }));

should be something like this

return chain.map((route, i) => ({
      id: route.id,
      path: route.path,
      params: mergeParams(route.params, allparams[i]),
      beforeEnter: route.beforeEnter,
      beforeLeave: route.beforeLeave
    }));

Because then the navigation hooks are used in router.tsx

snippet

const beforeEnterHook = toChain && toChain[toChain.length - 1].beforeEnter;
const beforeLeaveHook = fromChain && fromChain[fromChain.length - 1].beforeLeave;

But since those properties where previously removed they are always undefined.

@ionitron-bot ionitron-bot bot added the triage label Nov 18, 2020
@liamdebeasi
Copy link
Contributor

Thanks for the issue. Can you provide a code reproduction of the issue and provide a link to the GitHub repo?

@liamdebeasi liamdebeasi added the ionitron: needs reproduction a code reproduction is needed from the issue author label Nov 18, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 18, 2020

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please provide a reproduction with the minimum amount of code required to reproduce the issue. Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

For a guide on how to create a good reproduction, see our Contributing Guide.

@ionitron-bot ionitron-bot bot removed the triage label Nov 18, 2020
@igorovic
Copy link
Author

Here is the reproduction code.

https://github.com/igorovic/ionic-bug-navhooks

You should check the file app-root.tsx

@liamdebeasi liamdebeasi removed the ionitron: needs reproduction a code reproduction is needed from the issue author label Nov 18, 2020
@liamdebeasi
Copy link
Contributor

Thanks! Can you try the following dev build and let me know if it resolves the issue?

npm install @ionic/core@5.5.0-dev.202011181622.33768e1

@igorovic
Copy link
Author

Yes it works 👍

Side note: My VScode ts linter is not happy with my custom component since I installed this dev build.

@liamdebeasi
Copy link
Contributor

Side note: My VScode ts linter is not happy with my custom component since I installed this dev build.

Are you getting an error?

@igorovic
Copy link
Author

Never mind, it's an issue in my custom component that broke the linter.

Regarding the navigation hook it's fixed in => @ionic/core@5.5.0-dev.202011181622.33768e1

@liamdebeasi
Copy link
Contributor

Glad it's fixed! Thanks for double checking the linter issue.

@igorovic
Copy link
Author

Thank you for the fix 👍 . I would have done it myself but I didn't read the contribution guide yet. 😄

@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #22521, and a fix will be available in an upcoming release of Ionic Framework.

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 18, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants