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 calls preventDefault on 'click' events #16779

Merged

Conversation

necolas
Copy link
Contributor

@necolas necolas commented Sep 13, 2019

Make sure to call preventDefault for any 'click' events that follow a 'keydown'
event that matches 'preventKeys'.

@sizebot
Copy link

sizebot commented Sep 13, 2019

Details of bundled changes.

Comparing: 137ea78...2353c0b

react-events

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-events-focus.development.js 0.0% 0.0% 10.91 KB 10.91 KB 2.36 KB 2.36 KB UMD_DEV
react-events-focus.production.min.js 0.0% 🔺+0.1% 4.09 KB 4.09 KB 1.39 KB 1.39 KB UMD_PROD
ReactEventsKeyboard-dev.js +8.2% +7.0% 5.48 KB 5.93 KB 1.93 KB 2.07 KB FB_WWW_DEV
react-events-swipe.production.min.js 0.0% 🔺+0.1% 2.43 KB 2.43 KB 1.1 KB 1.1 KB UMD_PROD
ReactEventsKeyboard-prod.js 🔺+8.4% 🔺+6.1% 4.33 KB 4.69 KB 1.46 KB 1.55 KB FB_WWW_PROD
react-events-swipe.development.js 0.0% +0.1% 5.81 KB 5.81 KB 1.58 KB 1.58 KB NODE_DEV
react-events-context-menu.production.min.js 0.0% 🔺+0.2% 1.19 KB 1.19 KB 664 B 665 B NODE_PROD
react-events-swipe.production.min.js 0.0% 🔺+0.1% 2.25 KB 2.25 KB 1.04 KB 1.04 KB NODE_PROD
react-events-hover.development.js 0.0% +0.1% 6.81 KB 6.81 KB 1.5 KB 1.5 KB NODE_DEV
react-events-focus.development.js 0.0% 0.0% 10.73 KB 10.73 KB 2.31 KB 2.31 KB NODE_DEV
react-events-keyboard.development.js +8.2% +6.8% 5.5 KB 5.95 KB 1.96 KB 2.09 KB UMD_DEV
react-events-keyboard.production.min.js 🔺+13.1% 🔺+6.4% 2.21 KB 2.5 KB 1.2 KB 1.28 KB UMD_PROD
react-events-tap.production.min.js 0.0% -0.0% 5.77 KB 5.77 KB 2.22 KB 2.22 KB UMD_PROD
react-events-drag.development.js 0.0% 0.0% 6.97 KB 6.97 KB 2.2 KB 2.2 KB NODE_DEV
react-events-keyboard.development.js +8.5% +7.1% 5.31 KB 5.76 KB 1.9 KB 2.04 KB NODE_DEV
react-events-keyboard.production.min.js 🔺+14.2% 🔺+6.6% 2.04 KB 2.32 KB 1.13 KB 1.21 KB NODE_PROD
react-events-tap.production.min.js 0.0% -0.0% 5.67 KB 5.67 KB 2.21 KB 2.2 KB NODE_PROD

Generated by 🚫 dangerJS against 2353c0b

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.

Some of the tests are failing but overall it looks okay.

@@ -150,6 +156,7 @@ function createKeyboardEvent(
isComposing,
key: getEventKey(nativeEvent),
metaKey,
pointerType: 'keyboard',
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need a pointerType for keyboard responder?

@@ -16,26 +16,32 @@ import React from 'react';
import {DiscreteEvent} from 'shared/ReactTypes';
import type {ReactEventResponderListener} from 'shared/ReactTypes';

type KeyboardEventType = 'keydown' | 'keyup';
type KeyboardEventType = 'keyboard:keydown' | 'keyboard:keyup';
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the keyboard prefix is because we're also adding the keyboard pointer type. What do you expect this to expand to in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should scope event names to their responder, especially given that keydown and keyup are also the names of native events

Make sure to call preventDefault for any 'click' events that follow a 'keydown'
event that matches 'preventKeys'
@necolas necolas force-pushed the react-events/use-keyboard-prevents-click branch from a3214b0 to 2353c0b Compare September 13, 2019 19:56
@necolas necolas merged commit 87eaa90 into facebook:master Sep 13, 2019
@necolas necolas deleted the react-events/use-keyboard-prevents-click branch December 20, 2019 15: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.

4 participants