-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Experimental event API: rework the propagation system for event components #15462
Conversation
be56d10
to
cff6f3e
Compare
Correct Drag and Swipe modules Fix tests Fix typo
cff6f3e
to
6c5f318
Compare
@necolas it would be good if you could validate this PR locally when you get a chance against your codesandbox. Thanks! |
ReactDOM: size: 0.0%, gzip: -0.0% Details of bundled changes.Comparing: 5876769...c9a7fa7 react-dom
react-events
Generated by 🚫 dangerJS |
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.
Looks good. I can test this patch in the sandbox after the merge conflicts with master are resolved.
About the names, we could probably follow existing naming convention in React for bubble vs capture phase, e.g., onClick
/onClickCapture
.
onBubbledTargetEvent
-> onEvent
or onTargetEvent
onCapturedTargetEvent
-> onEventCapture
or onTargetEventCapture
Might be worth avoiding the word target
though as it's used in a few places to mean different things at the moment.
@necolas I've fixed the conflicts with master and applied the name change that you suggested. I'll let you test it first – if it's all good, feel free to merge or wait till I'm back in the office. :) |
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.
Sandbox (updated to use this patch) seems to be working as before: https://fburl.com/nfye4390
After much discussion with @necolas and quite a bit of internal testing, we came up with an idea to improve the experimental event API and its propagation system. Rather than return a
boolean
from the event responderonHandle
to indicate if an event should be propagated, all events are now propagated depending on the responder and the event component.Responders now have the
stopLocalPropagation
option (required). This tells the event system what it should do we encountering this particular event responder. If this flag is set totrue
, then when we encounter the same event responder during propagation, we skip calling the event listeners on that responder for that event component.Furthermore, there was some confusion over the phases on the event object, and so now
onHandle
has been split into three methods:onEvent
,onEventCapture
andonRootEvent
.Ref #15257