diff --git a/src/common/Input.js b/src/common/Input.js index 345114dc27a..dd9813309a5 100644 --- a/src/common/Input.js +++ b/src/common/Input.js @@ -8,7 +8,10 @@ import type { ThemeData } from '../styles'; import { ThemeContext, HALF_COLOR, BORDER_COLOR } from '../styles'; export type Props = $ReadOnly<{| - ...$PropertyType, + // See point 2 at + // https://github.com/facebook/react-native/issues/28459#issuecomment-609957836 + // $FlowFixMe + ...$PropertyType, placeholder: LocalizableText, onChangeText?: (text: string) => void, textInputRef?: React$Ref, diff --git a/src/common/InputWithClearButton.js b/src/common/InputWithClearButton.js index 0482cc4bce4..87bdeec86b4 100644 --- a/src/common/InputWithClearButton.js +++ b/src/common/InputWithClearButton.js @@ -32,7 +32,7 @@ export default class InputWithClearButton extends PureComponent { canBeCleared: false, text: '', }; - textInputRef = React.createRef(); + textInputRef = React.createRef(); handleChangeText = (text: string) => { this.setState({ @@ -47,6 +47,9 @@ export default class InputWithClearButton extends PureComponent { handleClear = () => { this.handleChangeText(''); if (this.textInputRef.current) { + // See point 2 at + // https://github.com/facebook/react-native/issues/28459#issuecomment-609957836 + // $FlowFixMe this.textInputRef.current.clear(); } }; diff --git a/src/common/SmartUrlInput.js b/src/common/SmartUrlInput.js index a8aa400253e..67f8461adc5 100644 --- a/src/common/SmartUrlInput.js +++ b/src/common/SmartUrlInput.js @@ -66,12 +66,15 @@ export default class SmartUrlInput extends PureComponent { state = { value: '', }; - textInputRef = React.createRef(); + textInputRef = React.createRef(); focusListener: void | NavigationEventSubscription; componentDidMount() { this.focusListener = this.props.navigation.addListener('didFocus', () => { if (this.textInputRef.current) { + // See point 2 at + // https://github.com/facebook/react-native/issues/28459#issuecomment-609957836 + // $FlowFixMe this.textInputRef.current.focus(); } }); @@ -93,9 +96,13 @@ export default class SmartUrlInput extends PureComponent { urlPress = () => { const { textInputRef } = this; if (textInputRef.current) { + // See point 2 at + // https://github.com/facebook/react-native/issues/28459#issuecomment-609957836 + // $FlowFixMe textInputRef.current.blur(); setTimeout(() => { if (textInputRef.current) { + // $FlowFixMe - same as above textInputRef.current.focus(); } }, 100); diff --git a/src/compose/ComposeBox.js b/src/compose/ComposeBox.js index 2af032043fb..b55867fa23e 100644 --- a/src/compose/ComposeBox.js +++ b/src/compose/ComposeBox.js @@ -105,13 +105,16 @@ function randomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } -export const updateTextInput = (textInput: TextInput | null, text: string): void => { +export const updateTextInput = (textInput: typeof TextInput | null, text: string): void => { if (textInput === null) { // Depending on the lifecycle events this function is called from, // this might not be set yet. return; } + // See point 2 at + // https://github.com/facebook/react-native/issues/28459#issuecomment-609957836 + // $FlowFixMe textInput.setNativeProps({ text }); if (text.length === 0 && TextInputReset) { @@ -125,8 +128,8 @@ class ComposeBox extends PureComponent { static contextType = ThemeContext; context: ThemeData; - messageInputRef = React.createRef(); - topicInputRef = React.createRef(); + messageInputRef = React.createRef(); + topicInputRef = React.createRef(); // TODO: Type-check this, once we've adjusted our `react-redux` // wrapper to do the right thing. It should be @@ -337,6 +340,9 @@ class ComposeBox extends PureComponent { } completeEditMessage(); if (this.messageInputRef.current !== null) { + // See point 2 at + // https://github.com/facebook/react-native/issues/28459#issuecomment-609957836 + // $FlowFixMe this.messageInputRef.current.blur(); } }; @@ -351,6 +357,9 @@ class ComposeBox extends PureComponent { this.setMessageInputValue(message); this.setTopicInputValue(topic); if (this.messageInputRef.current !== null) { + // See point 2 at + // https://github.com/facebook/react-native/issues/28459#issuecomment-609957836 + // $FlowFixMe this.messageInputRef.current.focus(); } }