GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [react-ui] usePress from useKeyboard and useTap (#16772) · react/react@3af05de

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-ui
    • accessibility/src
      • FocusGrid.js
      • ReactTabFocus.js
    • events
      • press-legacy.js
      • src/dom
        • Keyboard.js
        • Press.js
        • PressLegacy.js
        • Tap.js
        • __tests__
          • Keyboard-test.internal.js
          • MixedResponders-test-internal.js
          • Press-test.internal.js
          • PressLegacy-test.internal.js
          • Tap-test.internal.js
    • npm
      • drag.js
      • focus.js
      • hover.js
      • input.js
      • keyboard.js
      • press-legacy.js
      • press.js
      • scroll.js
      • swipe.js
      • tap.js
    • package.json
  • scripts
    • rollup
      • bundles.js
      • modules.js
    • shared
      • pathsByLanguageVersion.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-ui/accessibility/src/FocusGrid.js‎

Copy file name to clipboardExpand all lines: packages/react-ui/accessibility/src/FocusGrid.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* @flow
88
*/
99

10-
import type {KeyboardEvent} from 'react-ui/events/src/dom/Keyboard';
10+
import type {KeyboardEvent} from 'react-ui/events/keyboard';
1111

1212
import React from 'react';
1313
import {tabFocusableImpl} from './TabbableScope';
14-
import {useKeyboard} from '../../events/keyboard';
14+
import {useKeyboard} from 'react-ui/events/keyboard';
1515

1616
type GridComponentProps = {
1717
children: React.Node,
Collapse file

‎packages/react-ui/accessibility/src/ReactTabFocus.js‎

Copy file name to clipboardExpand all lines: packages/react-ui/accessibility/src/ReactTabFocus.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
*/
99

1010
import type {ReactScopeMethods} from 'shared/ReactTypes';
11-
import type {KeyboardEvent} from 'react-ui/events/src/dom/Keyboard';
11+
import type {KeyboardEvent} from 'react-ui/events/keyboard';
1212

1313
import React from 'react';
1414
import {TabbableScope} from './TabbableScope';
15-
import {useKeyboard} from '../../events/keyboard';
15+
import {useKeyboard} from 'react-ui/events/keyboard';
1616

1717
type TabFocusControllerProps = {
1818
children: React.Node,
1919
contain?: boolean,
2020
};
21+
2122
const {useRef} = React;
2223

2324
function getTabbableNodes(scope: ReactScopeMethods) {
Collapse file

‎packages/react-ui/events/press-legacy.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
'use strict';
11+
12+
module.exports = require('./src/dom/PressLegacy');
Collapse file

‎packages/react-ui/events/src/dom/Keyboard.js‎

Copy file name to clipboardExpand all lines: packages/react-ui/events/src/dom/Keyboard.js
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type KeyboardProps = {|
2727
onClick?: (e: KeyboardEvent) => ?boolean,
2828
onKeyDown?: (e: KeyboardEvent) => ?boolean,
2929
onKeyUp?: (e: KeyboardEvent) => ?boolean,
30+
preventClick?: boolean,
3031
preventKeys?: PreventKeysArray,
3132
|};
3233

@@ -256,6 +257,12 @@ const keyboardResponderImpl = {
256257
);
257258
}
258259
} else if (type === 'click' && isVirtualClick(event)) {
260+
if (props.preventClick !== false) {
261+
// 'click' occurs before or after 'keyup', and may need native
262+
// behavior prevented
263+
nativeEvent.preventDefault();
264+
state.defaultPrevented = true;
265+
}
259266
const onClick = props.onClick;
260267
if (onClick != null) {
261268
dispatchKeyboardEvent(
@@ -266,10 +273,6 @@ const keyboardResponderImpl = {
266273
state.defaultPrevented,
267274
);
268275
}
269-
if (state.defaultPrevented && !nativeEvent.defaultPrevented) {
270-
// 'click' occurs before 'keyup' and may need native behavior prevented
271-
nativeEvent.preventDefault();
272-
}
273276
} else if (type === 'keyup') {
274277
state.isActive = false;
275278
const onKeyUp = props.onKeyUp;

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.