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] Keyboard responder propagation handling #16657

Merged
merged 3 commits into from
Sep 4, 2019

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Sep 4, 2019

This adds support for conditional Keyboard responder propagation, for where there are nested keyboard responders. To allow a onKeyDown or onKeyUp event to propagate the callback is required to return true to propagate a single responder level. This is done by providing a new method on context called continuePropagation – which tells the responder propagation system to propagate a single level after processing the current responder (of the same responder type).

I also had to remove the usage of invokeGuardedCallbackAndCatchFirstError when calling the user-land event callback. This was because the existing invokeGuardedCallbackAndCatchFirstError doesn't support returning a value from the callback – which is what we need here. Attempting to change the mechanics of the function seemed far too invasive, so we can test this approach out internally to see if we run into any issues (we shouldn't though).

@sizebot
Copy link

sizebot commented Sep 4, 2019

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

Details of bundled changes.

Comparing: 539640d...4290034

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% -0.0% 115.32 KB 115.32 KB 36.36 KB 36.36 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 142.1 KB 142.1 KB 37.12 KB 37.12 KB UMD_DEV
ReactDOM-dev.js +0.1% 0.0% 938.39 KB 938.92 KB 207.33 KB 207.4 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.8 KB 19.8 KB 7.36 KB 7.36 KB UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.78 KB 3.78 KB 1.53 KB 1.53 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 11.18 KB 11.18 KB 4.15 KB 4.15 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.2 KB 1.2 KB 703 B 702 B UMD_PROD
react-dom-test-utils.production.min.js 0.0% -0.0% 10.95 KB 10.95 KB 4.09 KB 4.09 KB NODE_PROD
react-dom.development.js +0.1% 0.0% 914.59 KB 915.12 KB 207.33 KB 207.43 KB UMD_DEV
react-dom.profiling.min.js 0.0% -0.0% 115.12 KB 115.12 KB 37.08 KB 37.08 KB UMD_PROFILING
react-dom.development.js +0.1% 0.0% 908.68 KB 909.21 KB 205.66 KB 205.73 KB NODE_DEV
ReactDOM-prod.js 🔺+0.1% 🔺+0.1% 371.9 KB 372.2 KB 68.17 KB 68.22 KB FB_WWW_PROD
ReactDOM-profiling.js +0.1% +0.1% 377.02 KB 377.32 KB 69.19 KB 69.24 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.75 KB 10.75 KB 3.68 KB 3.68 KB UMD_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 3.87 KB 3.87 KB 1.51 KB 1.51 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.49 KB 10.49 KB 3.58 KB 3.58 KB NODE_PROD

Generated by 🚫 dangerJS against 4290034

@trueadm trueadm merged commit 7126a37 into facebook:master Sep 4, 2019
@trueadm trueadm deleted the keyboard-propagation branch September 4, 2019 17:25
const previouslyInEventHandler = isInsideEventHandler;
try {
isInsideEventHandler = true;
const type = typeof value === 'object' && value !== null ? value.type : '';
invokeGuardedCallbackAndCatchFirstError(type, fn, undefined, value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a follow-up to fix this? It seems important that event handler doesn't crash the rest of the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I plan on addressing it this week.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was already fixed in a follow-up right? This guard is still there on master

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOL. I did, I’m clearly losing the plot.

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.

None yet

5 participants