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

Experimental Event API: adds stopPropagation by default to Press #15384

Merged
merged 3 commits into from
Apr 11, 2019

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Apr 11, 2019

This PR adds the default behaviour of stopping propagation on Press events, with the ability to override that feature using the stopPropagation prop. I also had to refactor the event propagation system to account for async event contexts, which means aligning context.setTimeout with context.clearTimeout so we can share actual timeouts where they have matching delays within the same context.

@sizebot
Copy link

sizebot commented Apr 11, 2019

ReactDOM: size: -0.0%, gzip: -0.0%

Details of bundled changes.

Comparing: a9eff32...965ec07

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.1% +0.1% 897.34 KB 898.51 KB 203.09 KB 203.36 KB UMD_DEV
react-dom.production.min.js -0.0% -0.0% 105.46 KB 105.43 KB 34.17 KB 34.16 KB UMD_PROD
react-dom.profiling.min.js -0.0% -0.0% 108.46 KB 108.43 KB 34.79 KB 34.78 KB UMD_PROFILING
react-dom.development.js +0.1% +0.1% 891.96 KB 893.13 KB 201.54 KB 201.82 KB NODE_DEV
react-dom.production.min.js -0.0% -0.0% 105.45 KB 105.42 KB 33.62 KB 33.61 KB NODE_PROD
react-dom.profiling.min.js -0.0% -0.0% 108.57 KB 108.54 KB 34.2 KB 34.19 KB NODE_PROFILING
ReactDOM-dev.js +0.1% +0.1% 918.17 KB 919.33 KB 203.34 KB 203.64 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.4% 🔺+0.4% 339.79 KB 341.06 KB 62.53 KB 62.81 KB FB_WWW_PROD
ReactDOM-profiling.js +0.4% +0.4% 346.9 KB 348.16 KB 64 KB 64.27 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js +0.1% +0.1% 897.66 KB 898.83 KB 203.22 KB 203.5 KB UMD_DEV
react-dom-unstable-fire.production.min.js -0.0% -0.0% 105.47 KB 105.44 KB 34.18 KB 34.17 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js -0.0% -0.0% 108.48 KB 108.45 KB 34.8 KB 34.79 KB UMD_PROFILING
react-dom-unstable-fire.development.js +0.1% +0.1% 892.29 KB 893.46 KB 201.67 KB 201.96 KB NODE_DEV
react-dom-unstable-fire.production.min.js -0.0% -0.0% 105.46 KB 105.43 KB 33.63 KB 33.62 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js -0.0% -0.0% 108.58 KB 108.55 KB 34.21 KB 34.2 KB NODE_PROFILING
ReactFire-dev.js +0.1% +0.1% 917.36 KB 918.52 KB 203.4 KB 203.69 KB FB_WWW_DEV
ReactFire-prod.js 🔺+0.4% 🔺+0.4% 328.46 KB 329.72 KB 60.24 KB 60.51 KB FB_WWW_PROD
ReactFire-profiling.js +0.4% +0.5% 335.51 KB 336.77 KB 61.66 KB 61.93 KB FB_WWW_PROFILING
react-dom-unstable-new-scheduler.development.js +0.1% +0.1% 890.47 KB 891.64 KB 200.93 KB 201.21 KB NODE_DEV
react-dom-unstable-new-scheduler.production.min.js -0.0% -0.0% 103.62 KB 103.59 KB 33.11 KB 33.1 KB NODE_PROD
react-dom-unstable-new-scheduler.profiling.min.js -0.0% -0.0% 106.96 KB 106.93 KB 33.99 KB 33.98 KB NODE_PROFILING
ReactDOMNewScheduler-dev.js +0.1% +0.1% 918.2 KB 919.36 KB 203.35 KB 203.64 KB FB_WWW_DEV
ReactDOMNewScheduler-prod.js 🔺+0.4% 🔺+0.5% 334.74 KB 336 KB 62.21 KB 62.49 KB FB_WWW_PROD
ReactDOMNewScheduler-profiling.js +0.4% +0.5% 340 KB 341.26 KB 63.22 KB 63.52 KB FB_WWW_PROFILING
react-dom-test-utils.development.js 0.0% 0.0% 54.29 KB 54.29 KB 15.02 KB 15.02 KB UMD_DEV
react-dom-test-utils.development.js 0.0% 0.0% 54.01 KB 54.01 KB 14.95 KB 14.96 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.31 KB 10.31 KB 3.82 KB 3.82 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.76 KB 60.76 KB 15.85 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.69 KB 10.69 KB 3.67 KB 3.67 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.43 KB 60.43 KB 15.72 KB 15.72 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 10.42 KB 10.42 KB 3.56 KB 3.57 KB NODE_PROD
react-dom-server.browser.development.js 0.0% -0.0% 136.83 KB 136.83 KB 35.97 KB 35.96 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.18 KB 19.18 KB 7.21 KB 7.21 KB UMD_PROD
react-dom-server.browser.development.js 0.0% -0.0% 132.96 KB 132.96 KB 35.03 KB 35.02 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.1 KB 19.1 KB 7.2 KB 7.2 KB NODE_PROD
ReactDOMServer-prod.js 0.0% 0.0% 47.14 KB 47.14 KB 10.8 KB 10.8 KB FB_WWW_PROD
react-dom-server.node.development.js 0.0% -0.0% 134.9 KB 134.9 KB 35.58 KB 35.57 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.21 KB 1.21 KB 705 B 706 B UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.49 KB 3.49 KB 1.41 KB 1.41 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1.05 KB 1.05 KB 636 B 637 B NODE_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 3.74 KB 3.74 KB 1.43 KB 1.43 KB NODE_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.1 KB 1.1 KB 666 B 667 B NODE_PROD

react-events

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-events.development.js 0.0% +0.1% 1.59 KB 1.59 KB 686 B 687 B UMD_DEV
react-events.production.min.js 0.0% 🔺+0.2% 857 B 857 B 476 B 477 B UMD_PROD
react-events.production.min.js 0.0% 🔺+0.3% 698 B 698 B 399 B 400 B NODE_PROD
react-events-press.development.js +3.7% +2.3% 17.34 KB 17.98 KB 4.31 KB 4.41 KB UMD_DEV
react-events-press.production.min.js 🔺+4.4% 🔺+2.4% 6.94 KB 7.24 KB 2.46 KB 2.52 KB UMD_PROD
react-events-press.development.js +3.7% +2.4% 17.17 KB 17.81 KB 4.28 KB 4.38 KB NODE_DEV
react-events-press.production.min.js 🔺+4.5% 🔺+2.7% 6.77 KB 7.08 KB 2.41 KB 2.47 KB NODE_PROD
ReactEventsPress-dev.js +4.2% +2.8% 15.55 KB 16.21 KB 3.58 KB 3.67 KB FB_WWW_DEV
ReactEventsPress-prod.js 🔺+3.7% 🔺+1.7% 12.97 KB 13.46 KB 2.67 KB 2.71 KB FB_WWW_PROD
react-events-hover.development.js +0.2% +0.2% 6.74 KB 6.75 KB 1.79 KB 1.79 KB UMD_DEV
react-events-hover.production.min.js 🔺+0.1% 🔺+0.3% 3.02 KB 3.02 KB 1.15 KB 1.15 KB UMD_PROD
react-events-hover.development.js +0.2% +0.2% 6.57 KB 6.58 KB 1.74 KB 1.75 KB NODE_DEV
react-events-hover.production.min.js 🔺+0.1% 🔺+0.3% 2.85 KB 2.86 KB 1.1 KB 1.1 KB NODE_PROD
ReactEventsHover-dev.js +0.2% +0.1% 6.77 KB 6.79 KB 1.76 KB 1.77 KB FB_WWW_DEV
ReactEventsHover-prod.js 🔺+0.5% 🔺+0.3% 5.94 KB 5.96 KB 1.47 KB 1.47 KB FB_WWW_PROD
react-events-focus.development.js 0.0% +0.1% 3.29 KB 3.29 KB 1.11 KB 1.11 KB UMD_DEV
react-events-focus.production.min.js 0.0% 🔺+0.1% 1.52 KB 1.52 KB 738 B 739 B UMD_PROD
react-events-focus.development.js 0.0% +0.1% 3.12 KB 3.12 KB 1.06 KB 1.06 KB NODE_DEV
react-events-focus.production.min.js 0.0% 🔺+0.1% 1.35 KB 1.35 KB 671 B 672 B NODE_PROD
react-events-swipe.development.js 0.0% 0.0% 8.29 KB 8.29 KB 2.57 KB 2.57 KB UMD_DEV
react-events-swipe.production.min.js 0.0% 🔺+0.1% 3.29 KB 3.29 KB 1.55 KB 1.55 KB NODE_PROD

Generated by 🚫 dangerJS

@@ -477,6 +539,38 @@ describe('Event responder: Press', () => {
expect(onLongPress).not.toBeCalled();
});

it('is called but does not bubble', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's perform all the bubbling tests in the "nested responders" block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going to remove the nested responders block, as I thought it would be best to be about type of event. :/ I don't mind though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. But it seems we could test the bubbling/not-bubbling for all events in a single test.

Copy link
Contributor Author

@trueadm trueadm Apr 11, 2019

Choose a reason for hiding this comment

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

I'll do this in a follow up tomorrow, will need some re-organizing of the test file. I also want to add some more test coverage for Press too :)

I want to get this in for now, so at least we have proper propagation stopping support.

@trueadm trueadm merged commit 9672cf6 into facebook:master Apr 11, 2019
@trueadm trueadm deleted the stop-propagation-support branch April 11, 2019 19:00
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