Repository navigation
fix(react): keep an IonPage in a modal from taking over the route #31865
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
+182
−3
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d85e35e
fix(react): stop an IonPage inside an inline overlay from replacing t…
ShaneK 7b57e13
fix(react): keep an ionPage outlet inside an inline overlay from stay…
ShaneK 1673992
Merge branch 'main' of github.com:ionic-team/ionic-framework into FW-…
ShaneK 73de678
test(react-router): reword overlay outlet comment to describe behavior
ShaneK 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
43 changes: 43 additions & 0 deletions
43
packages/react-router/test/base/src/pages/overlays/ModalIonPage.tsx
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 |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { IonButton, IonContent, IonHeader, IonModal, IonPage, IonTitle, IonToolbar } from '@ionic/react'; | ||
| import { useState } from 'react'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
|
|
||
| import TestDescription from '../../components/TestDescription'; | ||
|
|
||
| const ModalIonPage: React.FC = () => { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <IonPage data-pageid="modal-ionpage"> | ||
| <IonContent> | ||
| <IonButton id="openModal" onClick={() => setIsOpen(true)}> | ||
| Open Modal | ||
| </IonButton> | ||
| <IonButton id="push" onClick={() => navigate('/')}> | ||
| Push | ||
| </IonButton> | ||
| <TestDescription> | ||
| Tap "Open Modal", then "Close" inside the modal, then "Push". This page should hide and the home page should | ||
| show. | ||
| </TestDescription> | ||
| <IonModal isOpen={isOpen} onDidDismiss={() => setIsOpen(false)}> | ||
| <IonPage data-pageid="modal-ionpage-content"> | ||
| <IonHeader> | ||
| <IonToolbar> | ||
| <IonTitle>Modal</IonTitle> | ||
| </IonToolbar> | ||
| </IonHeader> | ||
| <IonContent> | ||
| <IonButton id="closeModal" onClick={() => setIsOpen(false)}> | ||
| Close | ||
| </IonButton> | ||
| </IonContent> | ||
| </IonPage> | ||
| </IonModal> | ||
| </IonContent> | ||
| </IonPage> | ||
| ); | ||
| }; | ||
|
|
||
| export default ModalIonPage; |
62 changes: 62 additions & 0 deletions
62
packages/react-router/test/base/src/pages/overlays/ModalRouterOutlet.tsx
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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { IonButton, IonContent, IonModal, IonPage, IonRouterOutlet } from '@ionic/react'; | ||
| import { useState } from 'react'; | ||
| import { Route } from 'react-router-dom'; | ||
|
|
||
| import TestDescription from '../../components/TestDescription'; | ||
|
|
||
| const ModalPageOne: React.FC = () => ( | ||
| <IonPage data-pageid="modal-outlet-one"> | ||
| <IonContent> | ||
| <IonButton id="goToTwo" routerLink="/overlays/modal-outlet/two"> | ||
| Go to Page Two | ||
| </IonButton> | ||
| </IonContent> | ||
| </IonPage> | ||
| ); | ||
|
|
||
| const ModalPageTwo: React.FC = () => ( | ||
| <IonPage data-pageid="modal-outlet-two"> | ||
| <IonContent> | ||
| <IonButton id="goBackToOne" routerLink="/overlays/modal-outlet" routerDirection="back"> | ||
| Back to Page One | ||
| </IonButton> | ||
| </IonContent> | ||
| </IonPage> | ||
| ); | ||
|
|
||
| const ModalRouterOutlet: React.FC = () => { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [isIonPageOpen, setIsIonPageOpen] = useState(false); | ||
|
|
||
| return ( | ||
| <IonPage data-pageid="modal-outlet"> | ||
| <IonContent> | ||
| <IonButton id="openModal" onClick={() => setIsOpen(true)}> | ||
| Open Modal | ||
| </IonButton> | ||
| <IonButton id="openIonPageModal" onClick={() => setIsIonPageOpen(true)}> | ||
| Open Modal (ionPage outlet) | ||
| </IonButton> | ||
| <TestDescription> | ||
| Tap "Open Modal", then "Go to Page Two" and "Back to Page One" inside the modal. The modal should switch | ||
| between its two pages, and this page should still be showing behind it. "Open Modal (ionPage outlet)" should | ||
| do the same with an outlet that has the ionPage prop. | ||
| </TestDescription> | ||
| <IonModal isOpen={isOpen} onDidDismiss={() => setIsOpen(false)}> | ||
| <IonRouterOutlet> | ||
| <Route path="/overlays/modal-outlet" element={<ModalPageOne />} /> | ||
| <Route path="/overlays/modal-outlet/two" element={<ModalPageTwo />} /> | ||
| </IonRouterOutlet> | ||
| </IonModal> | ||
| <IonModal isOpen={isIonPageOpen} onDidDismiss={() => setIsIonPageOpen(false)}> | ||
| <IonRouterOutlet ionPage> | ||
| <Route path="/overlays/modal-outlet" element={<ModalPageOne />} /> | ||
| <Route path="/overlays/modal-outlet/two" element={<ModalPageTwo />} /> | ||
| </IonRouterOutlet> | ||
| </IonModal> | ||
| </IonContent> | ||
| </IonPage> | ||
| ); | ||
| }; | ||
|
|
||
| export default ModalRouterOutlet; |
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
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.
Uh oh!
There was an error while loading. Please reload this page.