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: fix press end event dispatching #15500

Merged

Conversation

necolas
Copy link
Contributor

@necolas necolas commented Apr 25, 2019

This patch fixes an issue related to determining whether the end event occurs
within the responder region. Previously we only checked if the event target was
within the responder region for moves, otherwise we checked if the target was
within the event component. Since the dimensions of the child element can
change after activation, we need to recalculate the responder region before
deactivation as well if the target is not within the event component.

Ref #15257

@sebmarkbage
Copy link
Collaborator

Regression tests?

@sizebot
Copy link

sizebot commented Apr 25, 2019

Details of bundled changes.

Comparing: d1f667a...f3aa134

react-events

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-events.development.js 0.0% +0.2% 1.16 KB 1.16 KB 616 B 617 B UMD_DEV
react-events.production.min.js 0.0% 🔺+0.5% 682 B 682 B 429 B 431 B UMD_PROD
react-events.development.js 0.0% +0.2% 996 B 996 B 554 B 555 B NODE_DEV
react-events.production.min.js 0.0% 🔺+0.3% 512 B 512 B 352 B 353 B NODE_PROD
react-events-Press.development.js +10.5% +7.8% 17.58 KB 19.42 KB 4.51 KB 4.86 KB UMD_DEV
react-events-Press.production.min.js 🔺+9.5% 🔺+6.0% 6.79 KB 7.43 KB 2.56 KB 2.71 KB UMD_PROD
react-events-Press.development.js +10.6% +7.8% 17.41 KB 19.25 KB 4.47 KB 4.82 KB NODE_DEV
react-events-Press.production.min.js 🔺+9.7% 🔺+6.2% 6.63 KB 7.27 KB 2.5 KB 2.66 KB NODE_PROD
ReactEventsPress-dev.js +13.2% +10.2% 15.47 KB 17.52 KB 3.74 KB 4.12 KB FB_WWW_DEV
ReactEventsPress-prod.js 🔺+10.7% 🔺+8.1% 12.99 KB 14.38 KB 2.86 KB 3.09 KB FB_WWW_PROD
react-events-Hover.production.min.js 0.0% 🔺+0.1% 3.89 KB 3.89 KB 1.44 KB 1.45 KB UMD_PROD
react-events-Hover.development.js 0.0% -0.0% 9.31 KB 9.31 KB 2.32 KB 2.32 KB NODE_DEV
react-events-Hover.production.min.js 0.0% 🔺+0.1% 3.73 KB 3.73 KB 1.4 KB 1.4 KB NODE_PROD
react-events-Focus.production.min.js 0.0% 🔺+0.2% 1.75 KB 1.75 KB 805 B 807 B UMD_PROD
react-events-Focus.production.min.js 0.0% 🔺+0.3% 1.58 KB 1.58 KB 736 B 738 B NODE_PROD
react-events-FocusScope.production.min.js 0.0% 🔺+0.1% 2 KB 2 KB 959 B 960 B UMD_PROD
react-events-FocusScope.production.min.js 0.0% 🔺+0.2% 1.79 KB 1.79 KB 905 B 907 B NODE_PROD
react-events-Drag.development.js 0.0% -0.0% 7.94 KB 7.94 KB 2.45 KB 2.45 KB UMD_DEV
react-events-Drag.production.min.js 0.0% -0.1% 3.37 KB 3.37 KB 1.53 KB 1.53 KB UMD_PROD

Generated by 🚫 dangerJS

if (pointerType === 'keyboard') {
if (!isValidKeyPress(nativeEvent.key)) {
return;
}
// If the event isn't within the event target, check if we're still within the responder region.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be:

If the event target isn't within the press target?

Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

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

The implementation makes sense. It would be good to have another test or two before, as I feel like this is likely to break when we refactor Press in the future.

@necolas necolas force-pushed the react-events/press-responder-region branch from 37e9737 to de53925 Compare April 25, 2019 18:29
@necolas
Copy link
Contributor Author

necolas commented Apr 25, 2019

What additional test coverage do you want?

@necolas necolas force-pushed the react-events/press-responder-region branch from de53925 to 1f3a8bd Compare April 25, 2019 18:43
@trueadm
Copy link
Contributor

trueadm commented Apr 25, 2019

@necolas I see you added tests. I was probably looking at an older commit.

This patch fixes an issue related to determining whether the end event occurs
within the responder region. Previously we only checked if the event target was
within the responder region for moves, otherwise we checked if the target was
within the event component. Since the dimensions of the child element can
change after activation, we need to recalculate the responder region before
deactivation as well if the target is not within the event component.
@necolas necolas force-pushed the react-events/press-responder-region branch from 1f3a8bd to f3aa134 Compare April 25, 2019 19:30
@necolas necolas merged commit 0b34311 into facebook:master Apr 25, 2019
@necolas necolas deleted the react-events/press-responder-region branch May 3, 2019 17:34
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.

5 participants