-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Closed
Labels
package: core@ionic/core package@ionic/core packagetype: buga confirmed bug reporta confirmed bug report
Milestone
Description
Bug Report
Ionic version:
[ ] 4.x
[x] 5.5.4
Current behavior:
I have a simple project with two routes /foo
and /bar
.
When I navigate to them via <ion-item button href=...>
the beforeEnter
hook is called as expected.
However when I visit navigate to my project by typing the url http://<site>/bar
then the beforeEnter
hook is not called.
I think this behavior is not expected ?
At least it could be a pain if you want to lazy-load the component in the beforeEnter
hook (or check authentication, ...)
Expected behavior:
The beforeEnter
hook should be called when directly navigating to the url, i.e. http://<site>/bar
Steps to reproduce:
- Navigate to https://runkit.com/vicb/ionic-router
- Click on "endpoint" at the to open the app,
- Open the console
- Click on go to bar / go to foo - you should see
beforeEnter
logs in the console - Manually update the url to end in "/foo" or "/bar",
- The content of
<ion-nav>
is updated as expected but thebeforeEnter
is not triggered (no logs).
Workaround:
A workaround would be to force an initial navigation after the router is loaded:
customElements.whenDefined('ion-router').then(() => {
const router = document.querySelector('ion-router');
const target = ...;
router?.push(target, 'root');
});
Metadata
Metadata
Assignees
Labels
package: core@ionic/core package@ionic/core packagetype: buga confirmed bug reporta confirmed bug report