Skip to content
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

[react-events] Remove stopPropagation (Press) + use document for delegation #16730

Merged

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Sep 10, 2019

This PR does two things:

  • Removes the stopPropagation prop from the Press responder module. After internal inspection, this prop seems to have been misused internally because a misunderstanding on what it does. It thus makes sense to remove this prop, because it was always intended to be a temporary hack.
  • Ensure that we always listen to captures on the document. Given we no longer can use stopPropagation we no longer have the issue of blocking other event systems already on the document.

@sizebot
Copy link

sizebot commented Sep 10, 2019

Details of bundled changes.

Comparing: 4905590...4200261

react-events

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-events-press.development.js -2.4% -2.9% 21.21 KB 20.69 KB 4.96 KB 4.82 KB UMD_DEV
react-events-focus.production.min.js 0.0% -0.1% 4.09 KB 4.09 KB 1.39 KB 1.39 KB UMD_PROD
react-events-press.production.min.js -1.4% -0.8% 7.06 KB 6.96 KB 2.64 KB 2.61 KB UMD_PROD
react-events-input.development.js 0.0% -0.1% 4.51 KB 4.51 KB 1.44 KB 1.44 KB UMD_DEV
react-events-swipe.development.js 0.0% -0.1% 5.99 KB 5.99 KB 1.62 KB 1.62 KB UMD_DEV
react-events-input.production.min.js 0.0% -0.1% 1.83 KB 1.83 KB 979 B 978 B UMD_PROD
react-events-swipe.production.min.js 0.0% -0.1% 2.43 KB 2.43 KB 1.1 KB 1.1 KB UMD_PROD
react-events-context-menu.development.js 0.0% -0.1% 2.48 KB 2.48 KB 955 B 954 B NODE_DEV
react-events-input.production.min.js 0.0% -0.1% 1.65 KB 1.65 KB 912 B 911 B NODE_PROD
react-events-hover.production.min.js 0.0% -0.1% 2.93 KB 2.93 KB 1.07 KB 1.07 KB NODE_PROD
react-events-press.development.js -2.5% -2.9% 21.02 KB 20.51 KB 4.91 KB 4.77 KB NODE_DEV
react-events-focus.production.min.js 0.0% -0.1% 3.92 KB 3.92 KB 1.32 KB 1.32 KB NODE_PROD
react-events-press.production.min.js -1.4% -0.9% 6.88 KB 6.78 KB 2.58 KB 2.56 KB NODE_PROD
react-events-keyboard.production.min.js 0.0% -0.1% 2.26 KB 2.26 KB 1.22 KB 1.22 KB UMD_PROD
ReactEventsPress-dev.js -2.5% -3.1% 21.87 KB 21.32 KB 5.11 KB 4.96 KB FB_WWW_DEV
ReactEventsPress-prod.js -0.9% -0.5% 16.34 KB 16.2 KB 3.57 KB 3.56 KB FB_WWW_PROD
react-events-drag.production.min.js 0.0% -0.1% 2.87 KB 2.87 KB 1.38 KB 1.37 KB NODE_PROD
react-events-keyboard.production.min.js 0.0% -0.2% 2.08 KB 2.08 KB 1.16 KB 1.16 KB NODE_PROD

Generated by 🚫 dangerJS against 4200261

@necolas
Copy link
Contributor

necolas commented Sep 10, 2019

Given we no longer can use stopPropagation we no longer have the issue of blocking other event systems already on the document.

Any "responder" can still do nativeEvent.stopPropagation()

@trueadm
Copy link
Contributor Author

trueadm commented Sep 10, 2019

@necolas True, but this was an explicit prop, so maybe my wording was a bit off. People can always do anything in the responders themselves.

@necolas
Copy link
Contributor

necolas commented Sep 10, 2019

The point is that moving listeners back to the document means that the system can collide with external listeners also attached to the document. That's aside from remove the stopPropagation prop from Press, which we should definitely do.

@trueadm
Copy link
Contributor Author

trueadm commented Sep 10, 2019

@necolas I found a bunch of subtle bugs today when moving all to body. Previously, we accidentally assigned most events to body but with some on document. This meant that events like scroll worked on the document but don't work on body.

Copy link
Contributor

@necolas necolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can address potential collisions on the document later.

I found a bunch of subtle bugs today when moving all to body

Might be worth documenting those bugs in a comment on this PR so there's a record if this comes up again in the future.

packages/react-events/src/dom/Press.js Outdated Show resolved Hide resolved
@trueadm trueadm merged commit fd3e8cb into facebook:master Sep 10, 2019
@trueadm trueadm deleted the ensure-flare-events-are-on-same-element branch September 10, 2019 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants