Skip to content

Commit

Permalink
Rename to focusable
Browse files Browse the repository at this point in the history
  • Loading branch information
sweggersen committed Jun 14, 2019
1 parent 06fffc2 commit 2584046
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Libraries/Components/Touchable/TouchableBounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ const TouchableBounce = ((createReactClass({
nativeID={this.props.nativeID}
testID={this.props.testID}
hitSlop={this.props.hitSlop}
clickable={
this.props.clickable !== false &&
focusable={
this.props.focusable !== false &&
this.props.onPress !== undefined &&
!this.props.disabled
}
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ const TouchableHighlight = ((createReactClass({
nextFocusLeft={this.props.nextFocusLeft}
nextFocusRight={this.props.nextFocusRight}
nextFocusUp={this.props.nextFocusUp}
clickable={
this.props.clickable !== false && this.props.onPress !== undefined
focusable={
this.props.focusable !== false && this.props.onPress !== undefined
}
onClick={this.touchableHandlePress}
onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ const TouchableNativeFeedback = createReactClass({
nextFocusRight: this.props.nextFocusRight,
nextFocusUp: this.props.nextFocusUp,
hasTVPreferredFocus: this.props.hasTVPreferredFocus,
clickable:
this.props.clickable !== false &&
focusable:
this.props.focusable !== false &&
this.props.onPress !== undefined &&
!this.props.disabled,
onClick: this.touchableHandlePress,
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ const TouchableOpacity = ((createReactClass({
hasTVPreferredFocus={this.props.hasTVPreferredFocus}
tvParallaxProperties={this.props.tvParallaxProperties}
hitSlop={this.props.hitSlop}
clickable={
this.props.clickable !== false && this.props.onPress !== undefined
focusable={
this.props.focusable !== false && this.props.onPress !== undefined
}
onClick={this.touchableHandlePress}
onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ const TouchableWithoutFeedback = ((createReactClass({
return (React: any).cloneElement(child, {
...overrides,
accessible: this.props.accessible !== false,
clickable:
this.props.clickable !== false && this.props.onPress !== undefined,
focusable:
this.props.focusable !== false && this.props.onPress !== undefined,
onClick: this.touchableHandlePress,
onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder,
onResponderTerminationRequest: this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`TouchableHighlight renders correctly 1`] = `
<View
accessible={true}
clickable={false}
focusable={false}
isTVSelectable={true}
onClick={[Function]}
onResponderGrant={[Function]}
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/View/ViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ type AndroidViewProps = $ReadOnly<{|
nextFocusUp?: ?number,

/**
* Whether this `View` should be clickable with a non-touch click, eg. enter key on a hardware keyboard.
* Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
*
* @platform android
*/
clickable?: boolean,
focusable?: boolean,

/**
* The action to perform when this `View` is clicked on by a non-touch click, eg. enter key on a hardware keyboard.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ public void setCollapsable(ReactViewGroup view, boolean collapsable) {
// handled in NativeViewHierarchyOptimizer
}

@ReactProp(name = "clickable")
public void setClickable(final ReactViewGroup view, boolean clickable) {
if (clickable) {
@ReactProp(name = "focusable")
public void setFocusable(final ReactViewGroup view, boolean focusable) {
if (focusable) {
view.setOnClickListener(
new View.OnClickListener() {
@Override
Expand All @@ -245,6 +245,7 @@ public void onClick(View v) {
else {
view.setOnClickListener(null);
view.setClickable(false);
// Don't set view.setFocusable(false) because we might still want it to be focusable for accessibiliy reasons
}
}

Expand Down

0 comments on commit 2584046

Please sign in to comment.