diff --git a/app/components/post_textbox/post_textbox.js b/app/components/post_textbox/post_textbox.js index 531be6ba1..c28e081d2 100644 --- a/app/components/post_textbox/post_textbox.js +++ b/app/components/post_textbox/post_textbox.js @@ -3,7 +3,7 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; -import {Alert, BackHandler, Keyboard, Platform, Text, TextInput, TouchableOpacity, View} from 'react-native'; +import {Alert, BackHandler, Keyboard, Platform, Text, TouchableOpacity, View} from 'react-native'; import {intlShape} from 'react-intl'; import {General, RequestStatus} from 'mattermost-redux/constants'; import EventEmitter from 'mattermost-redux/utils/event_emitter'; @@ -11,6 +11,7 @@ import EventEmitter from 'mattermost-redux/utils/event_emitter'; import AttachmentButton from 'app/components/attachment_button'; import Autocomplete from 'app/components/autocomplete'; import FileUploadPreview from 'app/components/file_upload_preview'; +import QuickTextInput from 'app/components/quick_text_input'; import {INITIAL_HEIGHT, INSERT_TO_COMMENT, INSERT_TO_DRAFT, IS_REACTION_REGEX, MAX_CONTENT_HEIGHT, MAX_FILE_COUNT} from 'app/constants/post_textbox'; import {confirmOutOfOfficeDisabled} from 'app/utils/status'; import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; @@ -526,7 +527,7 @@ export default class PostTextbox extends PureComponent { {!channelIsReadOnly && attachmentButton} - { + if (!this.input) { + return; + } + + this.input.setNativeProps({text: this.props.value}); + this.storedValue = this.props.value; + } + + focus() { + this.input.focus(); + } + + blur() { + this.input.blur(); + } + + handleChangeText = (value) => { + this.storedValue = value; + + if (this.props.onChangeText) { + this.props.onChangeText(value); + } + } + + setInput = (input) => { + this.input = input; + } + + render() { + const props = {...this.props}; + + // Specifying a value or defaultValue cause the issues noted above + Reflect.deleteProperty(props, 'value'); + Reflect.deleteProperty(props, 'defaultValue'); + + return ( + + ); + } +} diff --git a/app/components/search_bar/search_bar.android.js b/app/components/search_bar/search_bar.android.js index b94f34eea..e3fb3c82d 100644 --- a/app/components/search_bar/search_bar.android.js +++ b/app/components/search_bar/search_bar.android.js @@ -5,13 +5,13 @@ import PropTypes from 'prop-types'; import { InteractionManager, Keyboard, - TextInput, StyleSheet, View, TouchableWithoutFeedback, } from 'react-native'; import Icon from 'react-native-vector-icons/MaterialIcons'; +import QuickTextInput from 'app/components/quick_text_input'; import CustomPropTypes from 'app/constants/custom_prop_types'; import {changeOpacity} from 'app/utils/theme'; @@ -212,7 +212,7 @@ export default class SearchBarAndroid extends PureComponent { color={tintColorSearch || placeholderTextColor} /> } - - - - - - -