-
Notifications
You must be signed in to change notification settings - Fork 13.3k
feat(nav): remove ion-router integration #31266
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
Open
ShaneK
wants to merge
3
commits into
major-9.0
Choose a base branch
from
FW-6976
base: major-9.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver | |
| - [Input](#version-9x-input) | ||
| - [Legacy Picker](#version-9x-legacy-picker) | ||
| - [Modal](#version-9x-modal) | ||
| - [Nav](#version-9x-nav) | ||
| - [Router Outlet](#version-9x-router-outlet) | ||
| - [Searchbar](#version-9x-searchbar) | ||
| - [Select](#version-9x-select) | ||
|
|
@@ -98,6 +99,32 @@ Sheet modals that relied on the handle being inert should set `handleBehavior="n | |
| <ion-modal handle-behavior="none"></ion-modal> | ||
| ``` | ||
|
|
||
| <h4 id="version-9x-nav">Nav</h4> | ||
|
|
||
| `ion-nav` no longer integrates with `ion-router`. It is now a standalone imperative stack navigation component, driven only through its own API (`root`, `push`, `pop`, `setRoot`, etc.) and `ion-nav-link`. | ||
|
|
||
| The following behaviors have been removed: | ||
|
|
||
| - The router no longer discovers or drives an `ion-nav`. Placing an `ion-nav` inside an `ion-router` no longer turns it into a routed outlet. | ||
| - Navigating an `ion-nav` (via `push`, `pop`, `ion-nav-link`, or the swipe-to-go-back gesture) no longer updates the URL, and the router's navigation guards no longer run for `ion-nav` transitions. | ||
| - The internal `setRouteId()` and `getRouteId()` methods and the `updateURL` nav option have been removed. | ||
|
|
||
| Apps that relied on `ion-nav` to update the URL (for example, pushing components and expecting the browser URL to change) should use `ion-router-outlet` for URL-based routing: | ||
|
|
||
| ```diff | ||
| - <ion-router> | ||
| - <ion-nav root="page-one"></ion-nav> | ||
| - </ion-router> | ||
| + <ion-router-outlet></ion-router-outlet> | ||
| ``` | ||
|
|
||
| An `ion-nav` can still be used inside a routed page for local, URL-less stack navigation: | ||
|
|
||
| ```html | ||
| <!-- Inside a routed page, an ion-nav manages a local, URL-less stack --> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we expand on this example? |
||
| <ion-nav root="page-one"></ion-nav> | ||
| ``` | ||
|
|
||
| <h4 id="version-9x-router-outlet">Router Outlet</h4> | ||
|
|
||
| `ion-router-outlet` now exposes a `swipeGesture` property that controls the swipe-to-go-back gesture per outlet. This property defaults to `true` in `"ios"` mode and `false` in `"md"` mode. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,14 +15,21 @@ | |
| </head> | ||
|
|
||
| <body> | ||
| <!-- | ||
| As of Ionic 9, ion-nav no longer integrates with ion-router. This page | ||
| reproduces the pattern from https://github.com/ionic-team/ionic-framework/issues/24641, | ||
| where an ion-router and an ion-nav coexist. The ion-nav must manage its own | ||
| stack via `root` and ion-nav-link, the URL must never change as the stack | ||
| changes, and the page must still finish loading even though the router has no | ||
| outlet to drive. | ||
| --> | ||
|
Comment on lines
+18
to
+25
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we document how these work together somewhere? Possibly at https://ionicframework.com/docs/api/nav? |
||
| <ion-app> | ||
| <ion-router> | ||
| <ion-router use-hash="true"> | ||
| <ion-route url="/" component="page-root"></ion-route> | ||
| <ion-route url="/page-one" component="page-one"></ion-route> | ||
| <ion-route url="/page-two" component="page-two"></ion-route> | ||
| <ion-route url="/page-three" component="page-three"></ion-route> | ||
| </ion-router> | ||
| <ion-nav></ion-nav> | ||
| <ion-nav root="page-root"></ion-nav> | ||
| </ion-app> | ||
|
|
||
| <script> | ||
|
|
@@ -78,36 +85,13 @@ <h1>Page One</h1> | |
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <h1>Page Two</h1> | ||
| <div> | ||
| <ion-nav-link router-direction="forward" component="page-three"> | ||
| <button class="next">Go to Page Three</button> | ||
| </ion-nav-link> | ||
| </div> | ||
| </ion-content> | ||
| `; | ||
| } | ||
| } | ||
| class PageThree extends HTMLElement { | ||
| connectedCallback() { | ||
| this.innerHTML = ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-buttons slot="start"> | ||
| <ion-back-button></ion-back-button> | ||
| </ion-buttons> | ||
| <ion-title>Page Three</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <h1>Page Three</h1> | ||
| </ion-content> | ||
| `; | ||
| } | ||
| } | ||
| customElements.define('page-root', PageRoot); | ||
| customElements.define('page-one', PageOne); | ||
| customElements.define('page-two', PageTwo); | ||
| customElements.define('page-three', PageThree); | ||
| </script> | ||
| </body> | ||
| </html> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this example incomplete?
Should it be something like this: