-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix(modal): allow interaction with parent content through sheet modals in child routes #30839
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
6
commits into
main
Choose a base branch
from
fix/sheet-modals
base: main
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.
+351
−13
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ea8a22d
chore(angular): reproducing issue where modals with showBackdrop=fals…
ShaneK cc6727a
fix(modal): allow interaction with parent content when sheet modal ha…
ShaneK ef60cf1
fix(modal): handle React template wrapper in child route pointer-even…
ShaneK 4454872
fix(modal): stop router from blocking when there's a backdrop breakpo…
ShaneK 38743ff
fix(modal): allow background interaction for sheet modals with backdr…
ShaneK 4ad27fb
fix(modal): fix recalculating isSheetModal for Angular
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
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
38 changes: 38 additions & 0 deletions
38
packages/angular/test/base/e2e/src/standalone/modal-child-route.spec.ts
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,38 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
|
|
||
| /** | ||
| * Tests for sheet modals in child routes with showBackdrop=false. | ||
| * Parent has buttons + nested outlet; child route contains only the modal. | ||
| * See https://github.com/ionic-team/ionic-framework/issues/30700 | ||
| */ | ||
| test.describe('Modals: Inline Sheet in Child Route (standalone)', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('/standalone/modal-child-route/child'); | ||
| }); | ||
|
|
||
| test('should render parent content and child modal', async ({ page }) => { | ||
| await expect(page.locator('#increment-btn')).toBeVisible(); | ||
| await expect(page.locator('#decrement-btn')).toBeVisible(); | ||
| await expect(page.locator('#background-action-count')).toHaveText('0'); | ||
| await expect(page.locator('ion-modal.show-modal')).toBeVisible(); | ||
| await expect(page.locator('#modal-content-loaded')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('should allow interacting with parent content while modal is open in child route', async ({ page }) => { | ||
| await expect(page.locator('ion-modal.show-modal')).toBeVisible(); | ||
|
|
||
| await page.locator('#increment-btn').click(); | ||
| await expect(page.locator('#background-action-count')).toHaveText('1'); | ||
| }); | ||
|
|
||
| test('should allow multiple interactions with parent content while modal is open', async ({ page }) => { | ||
| await expect(page.locator('ion-modal.show-modal')).toBeVisible(); | ||
|
|
||
| await page.locator('#increment-btn').click(); | ||
| await page.locator('#increment-btn').click(); | ||
| await expect(page.locator('#background-action-count')).toHaveText('2'); | ||
|
|
||
| await page.locator('#decrement-btn').click(); | ||
| await expect(page.locator('#background-action-count')).toHaveText('1'); | ||
| }); | ||
| }); |
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
33 changes: 33 additions & 0 deletions
33
...gular/test/base/src/app/standalone/modal-child-route/modal-child-route-child.component.ts
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,33 @@ | ||
| import { CommonModule } from '@angular/common'; | ||
| import { Component } from '@angular/core'; | ||
| import { IonContent, IonHeader, IonModal, IonTitle, IonToolbar } from '@ionic/angular/standalone'; | ||
|
|
||
| /** | ||
| * Child route component containing only the sheet modal with showBackdrop=false. | ||
| * Verifies issue https://github.com/ionic-team/ionic-framework/issues/30700 | ||
| */ | ||
| @Component({ | ||
| selector: 'app-modal-child-route-child', | ||
| template: ` | ||
| <ion-modal | ||
| [isOpen]="true" | ||
| [breakpoints]="[0.2, 0.5, 0.7]" | ||
| [initialBreakpoint]="0.5" | ||
| [showBackdrop]="false" | ||
| > | ||
| <ng-template> | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Modal in Child Route</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <p id="modal-content-loaded">Modal content loaded in child route</p> | ||
| </ion-content> | ||
| </ng-template> | ||
| </ion-modal> | ||
| `, | ||
| standalone: true, | ||
| imports: [CommonModule, IonContent, IonHeader, IonModal, IonTitle, IonToolbar], | ||
| }) | ||
| export class ModalChildRouteChildComponent {} |
38 changes: 38 additions & 0 deletions
38
...ular/test/base/src/app/standalone/modal-child-route/modal-child-route-parent.component.ts
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,38 @@ | ||
| import { Component } from '@angular/core'; | ||
| import { IonButton, IonContent, IonHeader, IonRouterOutlet, IonTitle, IonToolbar } from '@ionic/angular/standalone'; | ||
|
|
||
| /** | ||
| * Parent with interactive buttons and nested outlet for child route modal. | ||
| * See https://github.com/ionic-team/ionic-framework/issues/30700 | ||
| */ | ||
| @Component({ | ||
| selector: 'app-modal-child-route-parent', | ||
| template: ` | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Parent Page with Nested Route</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
| <ion-content class="ion-padding"> | ||
| <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;"> | ||
| <ion-button id="decrement-btn" (click)="decrement()">-</ion-button> | ||
| <p id="background-action-count">{{ count }}</p> | ||
| <ion-button id="increment-btn" (click)="increment()">+</ion-button> | ||
| </div> | ||
| <ion-router-outlet></ion-router-outlet> | ||
| </ion-content> | ||
| `, | ||
| standalone: true, | ||
| imports: [IonButton, IonContent, IonHeader, IonRouterOutlet, IonTitle, IonToolbar], | ||
| }) | ||
| export class ModalChildRouteParentComponent { | ||
| count = 0; | ||
|
|
||
| increment() { | ||
| this.count++; | ||
| } | ||
|
|
||
| decrement() { | ||
| this.count--; | ||
| } | ||
| } |
69 changes: 69 additions & 0 deletions
69
packages/react/test/base/src/pages/overlay-components/ModalSheetChildRoute.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,69 @@ | ||
| import React, { useState } from 'react'; | ||
| import { | ||
| IonButton, | ||
| IonContent, | ||
| IonHeader, | ||
| IonModal, | ||
| IonPage, | ||
| IonRouterOutlet, | ||
| IonTitle, | ||
| IonToolbar, | ||
| } from '@ionic/react'; | ||
| import { Route } from 'react-router'; | ||
|
|
||
| /** | ||
| * Parent component with counter buttons and nested router outlet. | ||
| * This reproduces the issue from https://github.com/ionic-team/ionic-framework/issues/30700 | ||
| * where sheet modals in child routes with showBackdrop=false block interaction with parent content. | ||
| */ | ||
| const ModalSheetChildRouteParent: React.FC = () => { | ||
| const [count, setCount] = useState(0); | ||
|
|
||
| return ( | ||
| <IonPage> | ||
| <IonHeader> | ||
| <IonToolbar> | ||
| <IonTitle>Parent Page with Nested Route</IonTitle> | ||
| </IonToolbar> | ||
| </IonHeader> | ||
| <IonContent className="ion-padding"> | ||
| <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '20px' }}> | ||
| <IonButton id="decrement-btn" onClick={() => setCount((c) => c - 1)}> | ||
| - | ||
| </IonButton> | ||
| <p id="background-action-count">{count}</p> | ||
| <IonButton id="increment-btn" onClick={() => setCount((c) => c + 1)}> | ||
| + | ||
| </IonButton> | ||
| </div> | ||
| </IonContent> | ||
| <IonRouterOutlet> | ||
| <Route path="/overlay-components/modal-sheet-child-route/child" component={ModalSheetChildRouteChild} /> | ||
| </IonRouterOutlet> | ||
| </IonPage> | ||
| ); | ||
| }; | ||
|
|
||
| const ModalSheetChildRouteChild: React.FC = () => { | ||
| return ( | ||
| <IonPage> | ||
| <IonModal | ||
| isOpen={true} | ||
| breakpoints={[0.2, 0.5, 0.7]} | ||
| initialBreakpoint={0.5} | ||
| showBackdrop={false} | ||
| > | ||
| <IonHeader> | ||
| <IonToolbar> | ||
| <IonTitle>Modal in Child Route</IonTitle> | ||
| </IonToolbar> | ||
| </IonHeader> | ||
| <IonContent className="ion-padding"> | ||
| <p id="modal-content-loaded">Modal content loaded in child route</p> | ||
| </IonContent> | ||
| </IonModal> | ||
| </IonPage> | ||
| ); | ||
| }; | ||
|
|
||
| export default ModalSheetChildRouteParent; |
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
37 changes: 37 additions & 0 deletions
37
packages/react/test/base/tests/e2e/specs/overlay-components/IonModalSheetChildRoute.cy.ts
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,37 @@ | ||
| /** | ||
| * Tests for sheet modals in child routes with showBackdrop=false. | ||
| * See https://github.com/ionic-team/ionic-framework/issues/30700 | ||
| */ | ||
| describe('IonModal: Sheet in Child Route with Nested Routing', () => { | ||
| beforeEach(() => { | ||
| cy.visit('/overlay-components/modal-sheet-child-route/child'); | ||
| }); | ||
|
|
||
| it('should render parent content and child modal', () => { | ||
| cy.get('#increment-btn').should('exist'); | ||
| cy.get('#decrement-btn').should('exist'); | ||
| cy.get('#background-action-count').should('have.text', '0'); | ||
| cy.get('ion-modal.show-modal').should('exist'); | ||
| cy.get('#modal-content-loaded').should('exist'); | ||
| }); | ||
|
|
||
| it('should allow interacting with parent content while modal is open in child route', () => { | ||
| // Wait for modal to be presented | ||
| cy.get('ion-modal.show-modal').should('exist'); | ||
|
|
||
| // Click the increment button in the parent content | ||
| cy.get('#increment-btn').click(); | ||
| cy.get('#background-action-count').should('have.text', '1'); | ||
| }); | ||
|
|
||
| it('should allow multiple interactions with parent content while modal is open', () => { | ||
| cy.get('ion-modal.show-modal').should('exist'); | ||
|
|
||
| cy.get('#increment-btn').click(); | ||
| cy.get('#increment-btn').click(); | ||
| cy.get('#background-action-count').should('have.text', '2'); | ||
|
|
||
| cy.get('#decrement-btn').click(); | ||
| cy.get('#background-action-count').should('have.text', '1'); | ||
| }); | ||
| }); |
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.