-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Add full TouchHitTarget hit slop (experimental event API) to ReactDOM #15308
Conversation
Adds hydration support
ReactDOM: size: 0.0%, gzip: 0.0% Details of bundled changes.Comparing: 49595e9...e5fe082 react-dom
react-art
react-native-renderer
react-test-renderer
react-noop-renderer
react-reconciler
Generated by 🚫 dangerJS |
The bundle size is interesting, although the non-min size goes up from 105.45 KB -> 105.52 KB, gzip actually goes down from 33.59 KB -> 33.56 KB. This doesn't seem like something I can get down, as I made a bunch of changes to places that can't DCE (switch cases that now contain |
so good |
packages/react-events/src/__tests__/TouchHitTarget-test.internal.js
Outdated
Show resolved
Hide resolved
let rightString = right ? `-${right}px;` : ''; | ||
let bottomString = bottom ? `-${bottom}px;` : ''; | ||
|
||
return `<div style="position:absolute;${topString}${leftString}${rightString}${bottomString}"></div>`; |
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's worth noting that this could result in an undesirable experience for mouse-based interactions if the client-side JS fix is unavailable.
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 sure how we tackle that one. Maybe @sebmarkbage had some ideas. I think you can maybe get away using some clever pointer
media queries in a stylesheet.
Build is failing because of some strange |
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
if (childFiber === null) { | ||
return false; | ||
} | ||
const parentFiber = childFiber.return; |
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.
Normally we avoid traversing Fibers outside the reconciler but we already cheat this rule in the existing event system - for the same reasons as here. So this is ok.
This PR is a complete replacement for the work suggested and originally started in #15261.
This PR aims add doing the following:
<TouchHitTarget>
elements. These elements can have optional numerical and nullabletop
,left
,right
andbottom
props.getEventTargetChildElement
andcommitEventTarget
.Furthermore, I found that we can't actually test the hit slop logic in JSDOM because it doesn't support a bunch of the DOM APIs that
<TouchHitTarget>
and respective event responders use. We'll need to come up with a different strategy for that, maybe @necolas has some ideas.Ref #15257