-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
refactor: Remove custom hit testing in usePress #7427
Conversation
// Release pointer capture so that touch interactions can leave the original target. | ||
// This enables onPointerLeave and onPointerEnter to fire. | ||
let target = e.target as Element; | ||
if ('releasePointerCapture' in target) { |
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.
not supported in jsdom
// Safari on iOS sometimes fires pointerup events, even | ||
// when the touch isn't over the target, so double check. | ||
if (e.button === 0 && isOverTarget(e, e.currentTarget)) { | ||
if (e.button === 0) { |
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 am not certain yet if this bug still exists in Safari. This was added in #335. Will need to test.
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.
Excited to get this into testing!
We tested it yesterday! Got a few fixes coming. |
Updated to address two issues found in testing:
This only happens in RSP v3, not in RAC, because we recently changed the DOM structure to no longer be nested there. In RSP we have an extra
This works as intended with mouse (matching native behavior), but it is weird with touch since the user might be trying to scroll. Updated this logic to only select during |
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.
submenus appear to be working correctly in s1 and s2
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.
LGTM, verified the menu/pickers/etc don't auto close on touch when attempting to scroll. Also verified submenus don't close when dragging off of them in touch anymore
Related to #1720, #2506, #5290
Back in #62 we implemented our own hit testing in usePress in order to work around a bug in pointer events in iOS 13. Now that this version is long gone, we can probably remove this and use the
onPointerLeave
andonPointerEnter
events instead. This depends on releasePointerCapture being called duringonPointerDown
on touch devices, so that the original target doesn't capture the pointer and cause the browser to retarget all events to it even outside the hit area.