diff --git a/packages/react-navigation/examples/NavigationPlayground/js/KeyboardHandlingExample.js b/packages/react-navigation/examples/NavigationPlayground/js/KeyboardHandlingExample.js index 7a0674a5..01e2ce76 100644 --- a/packages/react-navigation/examples/NavigationPlayground/js/KeyboardHandlingExample.js +++ b/packages/react-navigation/examples/NavigationPlayground/js/KeyboardHandlingExample.js @@ -24,9 +24,9 @@ class ScreenOne extends React.Component { } class ScreenTwo extends React.Component { - static navigationOptions = { - title: 'Screen w/ Input', - }; + static navigationOptions = ({ navigation }) => ({ + title: navigation.getParam('inputValue', 'Screen w/ Input'), + }); componentDidMount() { InteractionManager.runAfterInteractions(() => { @@ -41,6 +41,7 @@ class ScreenTwo extends React.Component { (this._textInput = c)} + onChangeText={inputValue => navigation.setParams({ inputValue })} style={{ backgroundColor: 'white', height: 24, diff --git a/packages/react-navigation/src/navigators/createKeyboardAwareNavigator.js b/packages/react-navigation/src/navigators/createKeyboardAwareNavigator.js index 8da2d5bf..5b76a5ac 100644 --- a/packages/react-navigation/src/navigators/createKeyboardAwareNavigator.js +++ b/packages/react-navigation/src/navigators/createKeyboardAwareNavigator.js @@ -39,10 +39,16 @@ export default Navigator => }; _handleTransitionStart = (transitionProps, prevTransitionProps) => { - const currentField = TextInput.State.currentlyFocusedField(); - if (currentField) { - TextInput.State.blurTextInput(currentField); + // TODO: We should not even have received the transition start event + // in the case where the index did not change, I believe. We + // should revisit this after 2.0 release. + if (transitionProps.index !== prevTransitionProps.index) { + const currentField = TextInput.State.currentlyFocusedField(); + if (currentField) { + TextInput.State.blurTextInput(currentField); + } } + this.props.onTransitionStart && this.props.onTransitionStart(transitionProps, prevTransitionProps); };