Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ShaneK
left a comment
There was a problem hiding this comment.
I've tested and reviewed this and it looks great! 🚀
| await expect(page.locator('#before')).toBeFocused(); | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
| }); | |
| }); | |
| test('should let focus leave a sheet modal below its backdropBreakpoint', async ({ page, pageUtils }) => { | |
| await page.setContent( | |
| ` | |
| <button id="before">Before</button> | |
| <ion-modal handle="false" initial-breakpoint="0.3" backdrop-breakpoint="0.5"> | |
| <button id="first">First</button><button id="last">Last</button> | |
| </ion-modal> | |
| <script> | |
| document.querySelector('ion-modal').breakpoints = [0.3, 0.5, 1]; | |
| </script> | |
| `, | |
| config | |
| ); | |
| const modal = page.locator('ion-modal'); | |
| const firstButton = page.locator('#first'); | |
| await modal.evaluate((el: HTMLIonModalElement) => el.present()); | |
| // present() moves focus into the overlay a frame after it resolves | |
| await page.waitForFunction(() => document.querySelector('ion-modal')!.contains(document.activeElement)); | |
| await firstButton.focus(); | |
| await pageUtils.pressKeys('Shift+Tab'); | |
| await expect(page.locator('#before')).toBeFocused(); | |
| // The focus trap turns back on above the backdropBreakpoint | |
| await modal.evaluate((el: HTMLIonModalElement) => el.setCurrentBreakpoint(1)); | |
| await firstButton.focus(); | |
| await pageUtils.pressKeys('Shift+Tab'); | |
| await expect(page.locator('#last')).toBeFocused(); | |
| }); |
Nit: I think a test for the sheet path would be nice to have too. Below the backdropBreakpoint, the class gets toggled with classList in sheet.ts rather than through the host, and both of the existing sheet focus tests still pass with the boundaries forced visible. This one fails in all 3 browsers when the hide rule breaks, and it also checks that the trap comes back above the breakpoint. It sets handle="false" since the handle is tabbable and would grab the first Shift+Tab. Up to you though, no action required!
There was a problem hiding this comment.
Good call, added in cfb2287. I also confirmed it fails in all 3 browsers when the hide rule in modal.scss is broken. Thanks!
…point Co-authored-by: ShaneK <561207+ShaneK@users.noreply.github.com>
Issue number: internal
What is the current behavior?
In Chrome 157 and later, pressing Tab on the last focusable element of a presented
ion-modalorion-popovermoves focus out of the overlay. Chrome now lets Tab move focus off the end of the page without firing afocusevent, so the document focus listener that traps focus never runs. Alert, action sheet and loading are not affected because they already render focusable sentinels around their content.What is the new behavior?
overlays.tsno longer wraps focus itself.focusTrap="false", or a sheet modal below itsbackdropBreakpoint), so focus can still leave the overlay.Does this introduce a breaking change?
Other information
main.textareainsideion-textareainstead of theion-textareahost, which matches Chrome and Safari. The extra Firefox-only Tab in the popover textarea test was removed.main.