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

Modern Event System: fix EnterLeave plugin logic #18830

Merged
merged 2 commits into from
May 5, 2020

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented May 5, 2020

Today we found an internal issue with the modern event system and the EnterLeave plugin. Specifically, we didn't track mouseout on the container, only in the portal. That's because the portal had a child contained onMouseEnter. This bug is actually very similar to that of the recent fix to #18720.

Making this change, so that we now register this plugin on each root container fixed that issue, but also brought about another issue. This was great though, as we had already solved this in the legacy EnterLeave plugin (I commented on it below). Taking that logic and bringing it to the modern event system fixed the failing issues and aligned the modern event system with the legacy one.

// We use ensureListeningTo because the container might
// be a COMMENT_NODE and this function handles events
// on comments for us.
ensureListeningTo(container, 'onMouseEnter');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is similar to what we did with the fix in #18720.

@facebook-github-bot facebook-github-bot added the React Core Team Opened by a member of the React Core Team label May 5, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented May 5, 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 2be41ca:

Sandbox Source
kind-feather-7ihue Configuration

@sizebot
Copy link

sizebot commented May 5, 2020

Details of bundled changes.

Comparing: 7992ca1...2be41ca

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-test-utils.development.js 0.0% 0.0% 75.29 KB 75.29 KB 20.19 KB 20.19 KB UMD_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.2% 5.36 KB 5.36 KB 1.8 KB 1.8 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 13.18 KB 13.18 KB 4.9 KB 4.9 KB UMD_PROD
ReactDOMTesting-dev.js 0.0% 0.0% 910.26 KB 910.48 KB 203.2 KB 203.28 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.2 KB 1.2 KB 705 B 704 B UMD_PROD
react-dom.development.js 0.0% 0.0% 941.78 KB 942.02 KB 206.16 KB 206.25 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 124.62 KB 124.63 KB 39.9 KB 39.9 KB UMD_PROD
ReactDOMForked-dev.js +0.1% +0.1% 1010.16 KB 1010.8 KB 226.77 KB 226.96 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 23.43 KB 23.43 KB 8.61 KB 8.61 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 128.49 KB 128.5 KB 41.05 KB 41.05 KB UMD_PROFILING
ReactDOMForked-prod.js 🔺+0.1% 🔺+0.2% 417.92 KB 418.38 KB 75.22 KB 75.39 KB FB_WWW_PROD
react-dom.development.js 0.0% 0.0% 896.63 KB 896.87 KB 203.6 KB 203.69 KB NODE_DEV
ReactDOMForked-profiling.js +0.1% +0.2% 427.62 KB 428.08 KB 76.88 KB 77.04 KB FB_WWW_PROFILING
react-dom.production.min.js 0.0% 0.0% 124.81 KB 124.81 KB 39 KB 39.01 KB NODE_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 23.32 KB 23.32 KB 8.6 KB 8.6 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 128.82 KB 128.82 KB 40.29 KB 40.3 KB NODE_PROFILING
ReactDOM-dev.js +0.1% +0.1% 1014.03 KB 1014.67 KB 226.01 KB 226.21 KB FB_WWW_DEV
ReactDOMServer-dev.js 0.0% -0.0% 160.35 KB 160.35 KB 40.85 KB 40.85 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.1% 🔺+0.2% 422.33 KB 422.78 KB 74.61 KB 74.78 KB FB_WWW_PROD
ReactDOM-profiling.js +0.1% +0.2% 433.23 KB 433.68 KB 76.44 KB 76.61 KB FB_WWW_PROFILING
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 5.61 KB 5.61 KB 1.87 KB 1.86 KB NODE_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% -0.3% 1.17 KB 1.17 KB 668 B 666 B NODE_PROD
ReactDOMTesting-prod.js 0.0% 0.0% 378.97 KB 379.01 KB 69.19 KB 69.19 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% -0.0% 70.12 KB 70.12 KB 19.68 KB 19.68 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 4.87 KB 4.87 KB 1.7 KB 1.7 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 13.06 KB 13.06 KB 4.81 KB 4.8 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1.02 KB 1.02 KB 618 B 617 B NODE_PROD
react-dom-server.node.development.js 0.0% -0.0% 153.96 KB 153.96 KB 40.77 KB 40.77 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 23.73 KB 23.73 KB 8.75 KB 8.75 KB NODE_PROD

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

Size changes (experimental)

Generated by 🚫 dangerJS against 2be41ca

@sizebot
Copy link

sizebot commented May 5, 2020

Details of bundled changes.

Comparing: 7992ca1...2be41ca

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactDOM-profiling.js +0.1% +0.2% 444.75 KB 445.21 KB 78.46 KB 78.63 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 0.0% -0.0% 13.05 KB 13.05 KB 4.8 KB 4.79 KB NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% -0.3% 1.16 KB 1.16 KB 660 B 658 B NODE_PROD
ReactDOMForked-dev.js +0.1% +0.1% 1.01 MB 1.01 MB 232.46 KB 232.66 KB FB_WWW_DEV
ReactDOMForked-prod.js 🔺+0.1% 🔺+0.2% 429.5 KB 429.96 KB 77.26 KB 77.44 KB FB_WWW_PROD
react-dom.development.js 0.0% 0.0% 907.99 KB 908.24 KB 199.7 KB 199.79 KB UMD_DEV
ReactDOMForked-profiling.js +0.1% +0.2% 439.26 KB 439.72 KB 78.9 KB 79.08 KB FB_WWW_PROFILING
react-dom.production.min.js 0.0% 0.0% 119.84 KB 119.84 KB 38.42 KB 38.43 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 123.61 KB 123.61 KB 39.63 KB 39.63 KB UMD_PROFILING
ReactDOMTesting-dev.js 0.0% 0.0% 936.05 KB 936.27 KB 208.74 KB 208.84 KB FB_WWW_DEV
react-dom.development.js 0.0% 0.0% 864.29 KB 864.52 KB 197.17 KB 197.26 KB NODE_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 390.83 KB 390.87 KB 71.18 KB 71.19 KB FB_WWW_PROD
react-dom.production.min.js 0.0% 0.0% 119.96 KB 119.96 KB 37.58 KB 37.58 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 123.85 KB 123.86 KB 38.8 KB 38.8 KB NODE_PROFILING
ReactDOM-dev.js +0.1% +0.1% 1.02 MB 1.02 MB 231.63 KB 231.83 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.1% 🔺+0.2% 433.79 KB 434.25 KB 76.61 KB 76.78 KB FB_WWW_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 5.6 KB 5.6 KB 1.85 KB 1.86 KB NODE_DEV
react-dom-server.browser.development.js 0.0% -0.0% 145.79 KB 145.79 KB 38.72 KB 38.72 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.2% 5.35 KB 5.35 KB 1.79 KB 1.8 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.19 KB 1.19 KB 698 B 697 B UMD_PROD
ReactDOMServer-dev.js 0.0% 0.0% 163.85 KB 163.85 KB 41.76 KB 41.76 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1 KB 1 KB 610 B 609 B NODE_PROD

Size changes (stable)

Generated by 🚫 dangerJS against 2be41ca

@trueadm trueadm force-pushed the fix-enter-leave-2 branch 2 times, most recently from 584652f to 751f4f5 Compare May 5, 2020 18:45
Add regression tests

Fix root code

Fix logic in DOMComponent

Fix unused var
// If we are not processing the first ancestor, then we
// should not process the same nativeEvent again, as we
// will have already processed it in the first ancestor.
const nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed feedback
@trueadm trueadm merged commit 823dc58 into facebook:master May 5, 2020
@trueadm trueadm deleted the fix-enter-leave-2 branch May 5, 2020 21:10
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