diff --git a/Button.js b/Button.js index 1980ca0..a9afc2c 100644 --- a/Button.js +++ b/Button.js @@ -8,6 +8,7 @@ import { StyleSheet, ActivityIndicator, TouchableNativeFeedback, + Keyboard, Platform } from 'react-native'; import isEqual from 'lodash.isequal'; @@ -30,6 +31,7 @@ const Button = React.createClass({ delayLongPress: PropTypes.number, delayPressIn: PropTypes.number, delayPressOut: PropTypes.number, + dismissKeyboard: PropTypes.bool, onPress: PropTypes.func, onLongPress: PropTypes.func, onPressIn: PropTypes.func, @@ -94,7 +96,10 @@ const Button = React.createClass({ let touchableProps = { accessibilityLabel: this.props.accessibilityLabel, onPress: this.props.onPress, - onPressIn: this.props.onPressIn, + onPressIn: () => { + this.props.dismissKeyboard && Keyboard.dismiss(); + this.props.onPressIn && this.props.onPressIn(); + }, onPressOut: this.props.onPressOut, onLongPress: this.props.onLongPress, activeOpacity: this.props.activeOpacity, diff --git a/README.md b/README.md index 0eb33e1..8a93ea5 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ your own styles to your child elements as you see fit. Multiple children are all | ``onLongPress`` | ``func`` | Function to execute when the ``onLongPress`` event is triggered. | | ``textStyle`` | ``TextStylePropTypes`` | The StyleSheet to apply to the inner button text. | | ``disabledStyle`` | ``TextStylePropTypes`` | The StyleSheet to apply when disabled. | +| ``dismissKeyboard`` | ``bool`` | Dismiss keyboard onPressIn | | ``children`` | ``string``, ``number``, ``React.Element``,or ``array`` | The child nodes to render inside the button. If child is ``string`` or ``number``, it will be rendered inside of a ```` element with ``textStyle`` applied if present. Multiple children are allowed (``array``).| | ``isLoading`` | ``bool`` | Renders an inactive state dimmed button with a spinner if ``true``. | | ``isDisabled`` | ``bool`` | Renders an inactive state dimmed button if ``true``. |