diff --git a/Libraries/Components/Button.js b/Libraries/Components/Button.js index 7a233cfc584edc..c442a2cf1a24ce 100644 --- a/Libraries/Components/Button.js +++ b/Libraries/Components/Button.js @@ -33,6 +33,11 @@ type ButtonProps = $ReadOnly<{| */ onPress: (event?: PressEvent) => mixed, + /** + * If true, doesn't play system sound on touch (Android Only) + **/ + touchSoundDisabled?: ?boolean, + /** * Color of the text (iOS), or background color of the button (Android) */ @@ -128,6 +133,7 @@ class Button extends React.Component { accessibilityLabel, color, onPress, + touchSoundDisabled, title, hasTVPreferredFocus, nextFocusDown, @@ -174,7 +180,8 @@ class Button extends React.Component { nextFocusUp={nextFocusUp} testID={testID} disabled={disabled} - onPress={onPress}> + onPress={onPress} + touchSoundDisabled={touchSoundDisabled}> {formattedTitle} diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 03aeeb9261b444..5eebe51deb096b 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -872,7 +872,7 @@ const TouchableMixin = { this._startHighlight(e); this._endHighlight(e); } - if (Platform.OS === 'android') { + if (Platform.OS === 'android' && !this.props.touchSoundDisabled) { this._playTouchSound(); } this.touchableHandlePress(e); diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 67c3c31eb6cbb8..8d317967e7c6f5 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -67,6 +67,7 @@ export type Props = $ReadOnly<{| disabled?: ?boolean, hitSlop?: ?EdgeInsetsProp, nativeID?: ?string, + touchSoundDisabled?: ?boolean, onBlur?: ?(e: BlurEvent) => void, onFocus?: ?(e: FocusEvent) => void, onLayout?: ?(event: LayoutEvent) => mixed, @@ -135,6 +136,10 @@ const TouchableWithoutFeedback = ((createReactClass({ * `{nativeEvent: {layout: {x, y, width, height}}}` */ onLayout: PropTypes.func, + /** + * If true, doesn't play system sound on touch (Android Only) + **/ + touchSoundDisabled: PropTypes.bool, onLongPress: PropTypes.func,