-
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
7
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.
Open
Changes from all commits
Commits
Show all changes
7 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 6780fad
fix(modal): cleaning up some repetitive code, adding links for test p…
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
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
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 | ||
| */ | ||
ShaneK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @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--; | ||
| } | ||
| } |
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.
I was testing this scenario manually and I'm not able to interact with the background. This is happening on Firefox, Chrome, and Safari.
Screen.Recording.2025-12-08.at.11.49.19.AM.mov
Uh oh!
There was an error while loading. Please reload this page.
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.
This works great for me in my testing, and worked for kumibrr here, so I'm unsure of what's going on 🤔
Maybe pull and try with my latest changes? That's real weird though!
Screenshot.2025-12-08.at.15.10.34.mp4
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.
I still had issues with the new code but I've approved it since the issue seems to be only on my end.