-
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
Try obviating Popover pointer event trap #59449
Conversation
Size Change: -363 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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 well in my testing, both in Storybook and in the editor itself.
Great cleanup and definitely a more elegant solution to the problem. Nice work @stokesman 🚀
Could you just add a CHANGELOG entry? I think it will be useful.
23b1b98
to
a7b49e6
Compare
Thanks for testing and reviewing Marin 🙇. I’ve added a changelog. |
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.
Thanks for working on a cleaner and simpler solution @stokesman 🙌 🚀
a7b49e6
to
21acd77
Compare
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.
Thanks for the simplification!
// iframes. If a newer version of react-colorful begins to employ | ||
// pointer capture this will be redundant and should be removed. | ||
onPointerDown={ ( { currentTarget, pointerId } ) => { | ||
currentTarget.setPointerCapture( pointerId ); |
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.
TIL setPointerCapture
!
) } | ||
<motion.div | ||
className={ classnames( 'components-popover', className, { |
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.
Good catch 🙏
* Partially revert "ColorPicker: improve UX of dragging the handle when in popover on top of the editor (WordPress#55149)" This reverts commit 9da6f48. * Use pointer capture to improve drag gesture UX * Use the context system again * Update snapshot * Remove unnecessary context provider * Add changelog entry
What?
Largely reverts the changes from #55149 and instead employs pointer capture in the color picker component.
Why?
Simplification.
How?
Using pointer capture during drag gestures prevents object like iframes from receiving pointer events and interfering with the drag gesture.
Testing Instructions
Testing Instructions for Keyboard
The changes here should only be relevant to the drag gestures which cannot be tested by keyboard.
Screenshots or screencast
color.picker.pointer.capture.mp4
More info
There is potential that a future version of the react-colorful library may use pointer capture itself and we'd be able to remove that from the ColorPicker component. A PR for such has been opened in the past and the author declined to merge at the time because they prioritize supporting older browsers. I'm pretty sure the WordPress policy on browser support is in the clear for use of PointerEvents/capture.