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

ReactDOM.useEvent: fix scope propagation issue #18464

Merged
merged 5 commits into from
Apr 2, 2020

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Apr 2, 2020

This PR fixes an issue with useEvent and scopes (see attached test). Specifically, we need to pass through the instance of the scope, so we can properly track if we can stopPropagation. Previously we used the currentTarget, which is the last physical DOM element. In the cases of scopes, this can be problematic if we have:

<Scope>
  <Scope>
    <div />
  </Scope>
</Scope>

To get around this we instead pass around an object, as { instance: Fiber | null, container: EventTarget }. We use this object to maintain the instance and contain (currentTarget) separately. I also moved the logic for this into the modern event system module so we don't affect other event systems with this change.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 2, 2020
@sizebot
Copy link

sizebot commented Apr 2, 2020

Details of bundled changes.

Comparing: 663c13d...006f23e

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.production.min.js 🔺+0.1% 🔺+0.2% 118.37 KB 118.53 KB 37.13 KB 37.18 KB NODE_PROD
react-dom-test-utils.development.js +0.1% 0.0% 60.94 KB 61.03 KB 16.09 KB 16.1 KB UMD_DEV
ReactDOMTesting-profiling.js +0.2% +0.1% 401.14 KB 401.86 KB 72.82 KB 72.86 KB FB_WWW_PROFILING
react-dom.profiling.min.js +0.1% +0.1% 122.23 KB 122.38 KB 38.28 KB 38.33 KB NODE_PROFILING
react-dom-test-utils.production.min.js 🔺+0.5% -0.0% 12.29 KB 12.34 KB 4.57 KB 4.57 KB UMD_PROD
ReactDOMForked-dev.js +0.3% +0.2% 990.16 KB 992.71 KB 219.78 KB 220.28 KB FB_WWW_DEV
ReactDOMForked-prod.js 🔺+0.5% 🔺+0.3% 415.48 KB 417.58 KB 74.83 KB 75.09 KB FB_WWW_PROD
react-dom.development.js 0.0% -0.0% 894.12 KB 894.44 KB 196.49 KB 196.41 KB UMD_DEV
ReactDOMForked-profiling.js +0.5% +0.3% 426.36 KB 428.46 KB 76.72 KB 76.97 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 133.89 KB 133.89 KB 34.5 KB 34.5 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.2% 118.27 KB 118.42 KB 37.9 KB 37.96 KB UMD_PROD
react-dom.profiling.min.js +0.1% +0.2% 121.98 KB 122.13 KB 39.04 KB 39.11 KB UMD_PROFILING
ReactDOMTesting-dev.js +0.1% 0.0% 944.86 KB 945.58 KB 210.48 KB 210.5 KB FB_WWW_DEV
react-dom.development.js 0.0% -0.0% 851.19 KB 851.49 KB 194.08 KB 194 KB NODE_DEV
ReactDOMTesting-prod.js 🔺+0.2% 🔺+0.1% 401.14 KB 401.86 KB 72.82 KB 72.86 KB FB_WWW_PROD
ReactDOM-dev.js +0.3% +0.2% 990.16 KB 992.71 KB 219.78 KB 220.28 KB FB_WWW_DEV
ReactDOMServer-dev.js 0.0% -0.0% 136.87 KB 136.87 KB 34.88 KB 34.88 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.5% 🔺+0.3% 415.48 KB 417.58 KB 74.83 KB 75.09 KB FB_WWW_PROD
react-dom-test-utils.development.js +0.1% +0.1% 56.33 KB 56.41 KB 15.48 KB 15.49 KB NODE_DEV
ReactDOMServer-prod.js 0.0% -0.0% 46.58 KB 46.58 KB 10.87 KB 10.87 KB FB_WWW_PROD
ReactDOM-profiling.js +0.5% +0.3% 426.36 KB 428.46 KB 76.72 KB 76.97 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 🔺+0.5% 🔺+0.1% 12.15 KB 12.2 KB 4.5 KB 4.5 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js +0.1% +0.1% 57.04 KB 57.12 KB 14.11 KB 14.12 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 🔺+0.6% -0.0% 10.29 KB 10.35 KB 3.49 KB 3.49 KB UMD_PROD
ReactTestUtils-dev.js +0.1% +0.1% 58.42 KB 58.49 KB 15.74 KB 15.75 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.development.js +0.1% +0.1% 54.08 KB 54.16 KB 13.9 KB 13.91 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 🔺+0.6% 🔺+0.1% 10.05 KB 10.1 KB 3.38 KB 3.39 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js -0.1% -0.1% 647.31 KB 646.93 KB 139.27 KB 139.13 KB RN_OSS_DEV
ReactNativeRenderer-prod.js -0.0% -0.0% 269.5 KB 269.41 KB 46.5 KB 46.48 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.0% -0.0% 281.41 KB 281.32 KB 48.71 KB 48.69 KB RN_OSS_PROFILING
ReactFabric-dev.js -0.1% -0.1% 628.99 KB 628.61 KB 134.84 KB 134.7 KB RN_OSS_DEV
ReactFabric-prod.js -0.0% -0.0% 261.48 KB 261.39 KB 45 KB 44.98 KB RN_OSS_PROD
ReactFabric-profiling.js -0.0% -0.0% 273.39 KB 273.3 KB 47.22 KB 47.2 KB RN_OSS_PROFILING

ReactDOM: size: 🔺+0.5%, gzip: -0.0%

Size changes (stable)

Generated by 🚫 dangerJS against 006f23e

@sizebot
Copy link

sizebot commented Apr 2, 2020

Details of bundled changes.

Comparing: 663c13d...006f23e

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestUtils-dev.js +0.1% +0.1% 58.41 KB 58.49 KB 15.75 KB 15.76 KB FB_WWW_DEV
react-dom.profiling.min.js +0.1% +0.1% 126.48 KB 126.64 KB 39.5 KB 39.55 KB NODE_PROFILING
ReactDOM-dev.js +0.3% +0.2% 962.51 KB 965.07 KB 213.55 KB 213.96 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.5% 🔺+0.4% 402.73 KB 404.82 KB 72.79 KB 73.08 KB FB_WWW_PROD
ReactDOM-profiling.js +0.5% +0.4% 413.54 KB 415.64 KB 74.64 KB 74.92 KB FB_WWW_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 4.35 KB 4.35 KB 1.52 KB 1.52 KB NODE_DEV
react-dom-test-utils.development.js +0.1% 0.0% 60.96 KB 61.04 KB 16.1 KB 16.1 KB UMD_DEV
react-dom-test-utils.production.min.js 🔺+0.5% -0.0% 12.3 KB 12.35 KB 4.58 KB 4.57 KB UMD_PROD
ReactDOMTesting-dev.js +0.1% 0.0% 918.4 KB 919.13 KB 204.71 KB 204.71 KB FB_WWW_DEV
ReactDOMTesting-prod.js 🔺+0.2% 🔺+0.1% 389.5 KB 390.22 KB 70.89 KB 70.96 KB FB_WWW_PROD
react-dom-test-utils.development.js +0.1% +0.1% 56.35 KB 56.43 KB 15.49 KB 15.5 KB NODE_DEV
ReactDOMTesting-profiling.js +0.2% +0.1% 389.5 KB 390.22 KB 70.89 KB 70.96 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 🔺+0.5% 🔺+0.1% 12.16 KB 12.22 KB 4.5 KB 4.51 KB NODE_PROD
react-dom-server.browser.development.js 0.0% -0.0% 128.51 KB 128.51 KB 34.27 KB 34.27 KB NODE_DEV
react-dom.development.js 0.0% -0.0% 923.95 KB 924.27 KB 201.79 KB 201.7 KB UMD_DEV
react-dom-unstable-native-dependencies.development.js +0.1% +0.1% 57.05 KB 57.13 KB 14.12 KB 14.13 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 122.33 KB 122.48 KB 39 KB 39.05 KB UMD_PROD
ReactDOMForked-dev.js +0.3% +0.2% 962.51 KB 965.07 KB 213.55 KB 213.96 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 🔺+0.5% -0.0% 10.31 KB 10.36 KB 3.5 KB 3.5 KB UMD_PROD
react-dom.profiling.min.js +0.1% +0.2% 126.15 KB 126.31 KB 40.25 KB 40.32 KB UMD_PROFILING
ReactDOMForked-prod.js 🔺+0.5% 🔺+0.4% 402.73 KB 404.82 KB 72.79 KB 73.08 KB FB_WWW_PROD
react-dom.development.js 0.0% -0.0% 879.78 KB 880.08 KB 199.31 KB 199.23 KB NODE_DEV
ReactDOMForked-profiling.js +0.5% +0.4% 413.54 KB 415.64 KB 74.64 KB 74.92 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.development.js +0.1% +0.1% 54.1 KB 54.17 KB 13.91 KB 13.92 KB NODE_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.2% 122.5 KB 122.66 KB 38.2 KB 38.26 KB NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 🔺+0.6% 🔺+0.1% 10.06 KB 10.12 KB 3.39 KB 3.39 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js -0.1% -0.1% 649.73 KB 649.35 KB 139.61 KB 139.47 KB RN_FB_DEV
ReactNativeRenderer-prod.js -0.0% -0.0% 269.66 KB 269.57 KB 46.54 KB 46.52 KB RN_FB_PROD
ReactNativeRenderer-profiling.js -0.0% -0.0% 281.56 KB 281.47 KB 48.74 KB 48.73 KB RN_FB_PROFILING
ReactFabric-dev.js -0.1% -0.1% 629 KB 628.63 KB 134.84 KB 134.7 KB RN_OSS_DEV
ReactFabric-prod.js -0.0% -0.0% 261.5 KB 261.41 KB 45 KB 44.99 KB RN_OSS_PROD
ReactFabric-profiling.js -0.0% -0.0% 273.4 KB 273.31 KB 47.23 KB 47.21 KB RN_OSS_PROFILING
ReactFabric-dev.js -0.1% -0.1% 631.42 KB 631.04 KB 135.15 KB 135.01 KB RN_FB_DEV
ReactFabric-prod.js -0.0% -0.0% 261.65 KB 261.56 KB 45.04 KB 45.02 KB RN_FB_PROD
ReactNativeRenderer-dev.js -0.1% -0.1% 647.32 KB 646.94 KB 139.28 KB 139.14 KB RN_OSS_DEV
ReactFabric-profiling.js -0.0% -0.0% 273.55 KB 273.46 KB 47.25 KB 47.24 KB RN_FB_PROFILING
ReactNativeRenderer-prod.js -0.0% -0.0% 269.51 KB 269.42 KB 46.51 KB 46.49 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.0% -0.0% 281.42 KB 281.33 KB 48.72 KB 48.7 KB RN_OSS_PROFILING

Size changes (experimental)

Generated by 🚫 dangerJS against 006f23e

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 2, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 006f23e:

Sandbox Source
heuristic-galileo-38lni Configuration

@trueadm trueadm force-pushed the fix-scope-prop branch 3 times, most recently from 254f61f to 10df875 Compare April 2, 2020 16:00
Address more feedback

Address more feedback

Address more feedback

Fix
Address more feedback
@trueadm trueadm merged commit 5e46454 into facebook:master Apr 2, 2020
@trueadm trueadm deleted the fix-scope-prop branch April 2, 2020 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants