-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Modal
: Nuance outside interactions
#52994
Conversation
onPointerUp: ( { target, isPrimary, button } ) => { | ||
const isSameTarget = target === pressTarget; | ||
pressTarget = null; | ||
if ( isPrimary && button === 0 && isSameTarget ) onRequestClose(); | ||
}, |
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 might be missing something obvious, but what stops us from simply doing this?
onPointerUp: ( { target, isPrimary, button } ) => { | |
const isSameTarget = target === pressTarget; | |
pressTarget = null; | |
if ( isPrimary && button === 0 && isSameTarget ) onRequestClose(); | |
}, | |
onClick: ( event ) => { | |
if ( event.target === event.currentTarget ) { | |
onRequestClose(); | |
} | |
}, |
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.
It wasn't immediately obvious to me. I tried that first and it works except for supporting the ability to drag back over the modal to cancel the click. When mousedown
is on the overlay and the mouseup
is on the modal that's still a click
from the perspective of the overlay (and target
is currentTarget
).
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.
Oh I see, good catch. Could we add a code comment about that too? I'm sure others will wonder the same.
Unfortunately this doesn't seem to be accurately testable in Jest, so I'll take note of it as a potential test to add when we set up Playwright tests for components.
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 think this is a pretty important improvement, let's move forward with it!
27a5661
to
5ae42a4
Compare
Thanks for reviewing Lena! I added a comment as suggested. I also removed the condition concerning |
5ae42a4
to
9b038fb
Compare
9b038fb
to
7feccc9
Compare
What?
Changes interactions on the overlay:
Why?
Some portion of the audience will appreciate these nuances and they don't otherwise negatively affect any UX.
How?
Uses pointer event handlers and:
pointerdown
if the overlay was pressed with the primary pointer then it’s tracked.pointerup
determines if the modal should be dismissed based on whether the overlay was the release target and whether the pointer (and button for mice) was primary.Testing Instructions
Testing Instructions for Keyboard
The changes in question aren’t keyboard applicable.
Screenshots or screencast