Skip to content

Commit

Permalink
Fix passthrough props on TouchableWithoutFeedback (facebook#592)
Browse files Browse the repository at this point in the history
* Fix passthrough props on TouchableWithoutFeedback

Most of the macOS-specific props should be passed through, but acceptsKeyboardFocus and enableFocusRing should default to true like the other Touchable components.

* Update snapshots with TouchableWithoutFeedback fix
  • Loading branch information
appden authored and alloy committed Sep 10, 2020
1 parent 6a8ff93 commit 3535ba7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

exports[`TextInput tests should render as expected: should deep render when mocked (please verify output manually) 1`] = `
<RCTSinglelineTextInputView
acceptsKeyboardFocus={true}
accessible={true}
allowFontScaling={true}
enableFocusRing={true}
focusable={true}
forwardedRef={null}
onBlur={[Function]}
Expand All @@ -28,8 +30,10 @@ exports[`TextInput tests should render as expected: should deep render when mock

exports[`TextInput tests should render as expected: should deep render when not mocked (please verify output manually) 1`] = `
<RCTSinglelineTextInputView
acceptsKeyboardFocus={true}
accessible={true}
allowFontScaling={true}
enableFocusRing={true}
focusable={true}
forwardedRef={null}
onBlur={[Function]}
Expand Down
11 changes: 10 additions & 1 deletion Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ const PASSTHROUGH_PROPS = [
'onFocus',
'onLayout',
'onMouseEnter', // [TODO(macOS ISS#2323203)
'onMouseLeave', // ]TODO(macOS ISS#2323203)
'onMouseLeave',
'onDragEnter',
'onDragLeave',
'onDrop',
'draggedTypes',
'tooltip', // ]TODO(macOS ISS#2323203)
'testID',
];

Expand Down Expand Up @@ -190,6 +195,10 @@ class TouchableWithoutFeedback extends React.Component<Props, State> {
accessible: this.props.accessible !== false,
focusable:
this.props.focusable !== false && this.props.onPress !== undefined,
acceptsKeyboardFocus:
this.props.acceptsKeyboardFocus !== false && !this.props.disabled, // [TODO(macOS ISS#2323203)
enableFocusRing:
this.props.enableFocusRing !== false && !this.props.disabled, // ]TODO(macOS ISS#2323203)
};
for (const prop of PASSTHROUGH_PROPS) {
if (this.props[prop] !== undefined) {
Expand Down

0 comments on commit 3535ba7

Please sign in to comment.