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

Add KeyboardEvent.code to synthetic event #18287

Merged
merged 3 commits into from Apr 4, 2020

Conversation

@bl00mber
Copy link
Contributor

@bl00mber bl00mber commented Mar 12, 2020

resolve #14102

@codesandbox
Copy link

@codesandbox codesandbox bot commented Mar 12, 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 223785a:

Sandbox Source
currying-butterfly-g8r6f Configuration
@sizebot
Copy link

@sizebot sizebot commented Mar 12, 2020

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against 223785a

@sizebot
Copy link

@sizebot sizebot commented Mar 12, 2020

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against 223785a

@bl00mber bl00mber force-pushed the bl00mber:bl00mber-patch-KeyboardEvent.code branch 5 times, most recently from 3cc717e to bbdec14 Mar 12, 2020
@bl00mber bl00mber force-pushed the bl00mber:bl00mber-patch-KeyboardEvent.code branch from bbdec14 to ee40b3f Mar 14, 2020
@@ -16,6 +16,12 @@ import getEventModifierState from './getEventModifierState';
*/
const SyntheticKeyboardEvent = SyntheticUIEvent.extend({
key: getEventKey,
code: function(event) {
if (event.type === 'keydown' || event.type === 'keyup') {

This comment has been minimized.

@gaearon

gaearon Apr 1, 2020
Member

Can we just have code: null? Why does it need special handling?

This comment has been minimized.

@bl00mber

bl00mber Apr 2, 2020
Author Contributor

I assumed this structure had something with react internals or KeyboardEvent specification because lower on this interface similar blocks are placed. When keypress callback is executed without react, code is equal to output of keydown and keyup events. However, if it executed with react, the output will be null.

@bl00mber bl00mber force-pushed the bl00mber:bl00mber-patch-KeyboardEvent.code branch from 7b9772a to c4e3619 Apr 2, 2020
);
expect(codeDown).toBe('KeyQ');
expect(codeUp).toBe('KeyQ');
expect(codePress).toBe(null);

This comment has been minimized.

@gaearon

gaearon Apr 3, 2020
Member

What does the spec say it should be?

This comment has been minimized.

@bl00mber

bl00mber Apr 4, 2020
Author Contributor

The spec says it should be a valid code. For some reason onKeyPress callback do not called when dispatched without charCode! I added charCode and codePress initializes now.

@bl00mber bl00mber force-pushed the bl00mber:bl00mber-patch-KeyboardEvent.code branch from 6fd72ce to 223785a Apr 4, 2020
@gaearon gaearon merged commit f625fce into facebook:master Apr 4, 2020
31 checks passed
31 checks passed
ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: build_devtools_and_process_artifacts Your tests passed on CircleCI!
Details
ci/circleci: build_experimental Your tests passed on CircleCI!
Details
ci/circleci: flow Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: lint_build Your tests passed on CircleCI!
Details
ci/circleci: process_artifacts Your tests passed on CircleCI!
Details
ci/circleci: process_artifacts_experimental Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: sizebot Your tests passed on CircleCI!
Details
ci/circleci: sizebot_experimental Your tests passed on CircleCI!
Details
ci/circleci: test_build Your tests passed on CircleCI!
Details
ci/circleci: test_build_experimental Your tests passed on CircleCI!
Details
ci/circleci: test_build_prod Your tests passed on CircleCI!
Details
ci/circleci: test_build_prod_experimental Your tests passed on CircleCI!
Details
ci/circleci: test_devtools Your tests passed on CircleCI!
Details
ci/circleci: test_dom_fixtures Your tests passed on CircleCI!
Details
ci/circleci: test_source Your tests passed on CircleCI!
Details
ci/circleci: test_source_experimental Your tests passed on CircleCI!
Details
ci/circleci: test_source_persistent Your tests passed on CircleCI!
Details
ci/circleci: test_source_prod Your tests passed on CircleCI!
Details
ci/circleci: test_source_prod_experimental Your tests passed on CircleCI!
Details
ci/circleci: test_source_www Your tests passed on CircleCI!
Details
ci/circleci: test_source_www_experimental Your tests passed on CircleCI!
Details
ci/circleci: test_source_www_prod Your tests passed on CircleCI!
Details
ci/circleci: test_source_www_prod_experimental Your tests passed on CircleCI!
Details
ci/circleci: test_source_www_variant Your tests passed on CircleCI!
Details
ci/circleci: test_source_www_variant_experimental Your tests passed on CircleCI!
Details
ci/circleci: test_source_www_variant_prod Your tests passed on CircleCI!
Details
ci/circleci: test_source_www_variant_prod_experimental Your tests passed on CircleCI!
Details
ci/codesandbox Building packages succeeded.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.