-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[DismissableLayer] Fix pointer-events issues #1401
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
Merged
benoitgrelard
merged 7 commits into
main
from
1241-1263-dismissable-layer-pointer-events-fixes
May 19, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2dc70ad
[DismissableLayer] Fix pointer-events issues
benoitgrelard 4ec8f25
PR feedback
benoitgrelard 745d65d
Add cypress tests
benoitgrelard 2511f31
testing flake
benoitgrelard f2baeec
Fix flake?
benoitgrelard 4d941df
Fix false positive
benoitgrelard 79b7eef
Copy change
benoitgrelard 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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| releases: | ||
| "@radix-ui/react-alert-dialog": patch | ||
| "@radix-ui/react-context-menu": patch | ||
| "@radix-ui/react-dialog": patch | ||
| "@radix-ui/react-dismissable-layer": patch | ||
| "@radix-ui/react-dropdown-menu": patch | ||
| "@radix-ui/react-hover-card": patch | ||
| "@radix-ui/react-menu": patch | ||
| "@radix-ui/react-navigation-menu": patch | ||
| "@radix-ui/react-popover": patch | ||
| "@radix-ui/react-select": patch | ||
| "@radix-ui/react-toast": patch | ||
| "@radix-ui/react-tooltip": patch | ||
|
|
||
| declined: | ||
| - primitives |
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 |
|---|---|---|
| @@ -1,11 +1,198 @@ | ||
| describe('Dialog', () => { | ||
| beforeEach(() => { | ||
| cy.visitStory('dialog--styled'); | ||
| cy.visitStory('dialog--cypress'); | ||
| }); | ||
|
|
||
| it('should open and close correctly', () => { | ||
| cy.findByText('open').click(); | ||
| cy.findByText('close').click(); | ||
| cy.findByText('close').should('not.exist'); | ||
| function shouldBeOpen() { | ||
| cy.findByText('title').should('exist'); | ||
| } | ||
| function shouldBeClosed() { | ||
| cy.findByText('title').should('not.exist'); | ||
| } | ||
| function shouldNotAllowOutsideInteraction(action: 'realClick' | 'realTouch') { | ||
| cy.findByLabelText('count up') | ||
| .invoke('text') | ||
| .then((count) => { | ||
| if (action === 'realTouch') { | ||
| cy.findByLabelText('count up').realClick(); | ||
| } else { | ||
| cy.findByLabelText('count up').realTouch(); | ||
| } | ||
| cy.findByLabelText('count up').should('have.text', count); | ||
| }); | ||
| } | ||
| function shouldAllowOutsideInteraction(action: 'realClick' | 'realTouch') { | ||
| cy.findByLabelText('count up') | ||
| .invoke('text') | ||
| .then((count) => { | ||
| if (action === 'realTouch') { | ||
| cy.findByLabelText('count up').realClick(); | ||
| } else { | ||
| cy.findByLabelText('count up').realTouch(); | ||
| } | ||
| cy.findByLabelText('count up').should('not.have.text', count); | ||
| }); | ||
| } | ||
|
|
||
| describe('given a modal dialog', () => { | ||
| it('can be open/closed with a keyboard', () => { | ||
| // using keyboard on open/close buttons | ||
| cy.findByText('open').focus(); | ||
| cy.realPress('Space'); | ||
| shouldBeOpen(); | ||
| cy.findByText('close').should('be.focused'); | ||
| cy.realPress('Space'); | ||
| shouldBeClosed(); | ||
| cy.findByText('open').should('be.focused'); | ||
|
|
||
| // using keyboard on open button and close with escape | ||
| cy.realPress('Space'); | ||
| shouldBeOpen(); | ||
| cy.realPress('Escape'); | ||
| shouldBeClosed(); | ||
| }); | ||
|
|
||
| it('can be open/closed with a pointer', () => { | ||
| // using pointer on open/close buttons | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByText('close').should('be.focused').click(); | ||
| shouldBeClosed(); | ||
| cy.findByText('open').should('be.focused'); | ||
|
|
||
| // using mouse inside dialog, then on a button outside | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByText('title').click(); | ||
| shouldBeOpen(); | ||
| shouldNotAllowOutsideInteraction('realClick'); | ||
| shouldBeClosed(); | ||
|
|
||
| // using touch on a button outside | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| shouldNotAllowOutsideInteraction('realTouch'); | ||
| shouldBeClosed(); | ||
|
|
||
| // using mouse on an input outside | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByPlaceholderText('name').realClick(); | ||
| cy.findByPlaceholderText('name').should('not.be.focused'); | ||
| shouldBeClosed(); | ||
|
|
||
| // using touch on an input outside | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByPlaceholderText('name').realTouch(); | ||
| cy.findByPlaceholderText('name').should('not.be.focused'); | ||
| shouldBeClosed(); | ||
|
|
||
| // turn on animation | ||
| cy.findByLabelText('animated').click(); | ||
|
|
||
| // using mouse on an input outside an animated dialog | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByPlaceholderText('name').realClick(); | ||
| cy.findByPlaceholderText('name').should('not.be.focused'); | ||
| shouldBeClosed(); | ||
|
|
||
| // finally, ensure that pointer-events have been reset and interactions restored | ||
| shouldAllowOutsideInteraction('realClick'); | ||
|
|
||
| // using touch on an input outside an animated dialog | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByPlaceholderText('name').realTouch(); | ||
| cy.findByPlaceholderText('name').should('not.be.focused'); | ||
| shouldBeClosed(); | ||
|
|
||
| // finally, ensure that pointer-events have been reset and interactions restored | ||
| shouldAllowOutsideInteraction('realTouch'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('given a non-modal dialog', () => { | ||
| beforeEach(() => { | ||
| cy.findByLabelText('modal').click(); | ||
| }); | ||
|
|
||
| it('can be open/closed with a keyboard', () => { | ||
| // using keyboard on open/close buttons | ||
| cy.findByText('open').focus(); | ||
| cy.realPress('Space'); | ||
| shouldBeOpen(); | ||
| cy.findByText('close').should('be.focused'); | ||
| cy.realPress('Space'); | ||
| shouldBeClosed(); | ||
| cy.findByText('open').should('be.focused'); | ||
|
|
||
| // using keyboard on open button and close with escape | ||
| cy.realPress('Space'); | ||
| shouldBeOpen(); | ||
| cy.realPress('Escape'); | ||
| shouldBeClosed(); | ||
| }); | ||
|
|
||
| it('can be open/closed with a pointer', () => { | ||
| // using pointer on open/close buttons | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByText('close').should('be.focused').click(); | ||
| shouldBeClosed(); | ||
| cy.findByText('open').should('be.focused'); | ||
|
|
||
| // using mouse inside dialog, then on a button outside | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByText('title').click(); | ||
| shouldBeOpen(); | ||
| shouldAllowOutsideInteraction('realClick'); | ||
| shouldBeClosed(); | ||
|
|
||
| // using touch on a button outside | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| shouldAllowOutsideInteraction('realTouch'); | ||
| shouldBeClosed(); | ||
|
|
||
| // using mouse on an input outside | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByPlaceholderText('name').realClick(); | ||
| cy.findByPlaceholderText('name').should('be.focused'); | ||
| shouldBeClosed(); | ||
|
|
||
| // using touch on an input outside | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByPlaceholderText('name').realTouch(); | ||
| cy.findByPlaceholderText('name').should('be.focused'); | ||
| shouldBeClosed(); | ||
|
|
||
| // turn on animation | ||
| cy.findByLabelText('animated').click(); | ||
|
|
||
| // using mouse on an input outside an animated dialog | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByPlaceholderText('name').realClick(); | ||
| cy.findByPlaceholderText('name').should('be.focused'); | ||
| shouldBeClosed(); | ||
|
|
||
| // finally, ensure that pointer-events have been reset and interactions restored | ||
| shouldAllowOutsideInteraction('realClick'); | ||
|
|
||
| // using touch on an input outside an animated dialog | ||
| cy.findByText('open').click(); | ||
| shouldBeOpen(); | ||
| cy.findByPlaceholderText('name').realTouch(); | ||
| cy.findByPlaceholderText('name').should('be.focused'); | ||
| shouldBeClosed(); | ||
|
|
||
| // finally, ensure that pointer-events have been reset and interactions restored | ||
| shouldAllowOutsideInteraction('realTouch'); | ||
| }); | ||
| }); | ||
| }); |
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.