diff --git a/app/components/autocomplete/at_mention/at_mention.js b/app/components/autocomplete/at_mention/at_mention.js index 2a9e90b33..5857eec75 100644 --- a/app/components/autocomplete/at_mention/at_mention.js +++ b/app/components/autocomplete/at_mention/at_mention.js @@ -26,8 +26,8 @@ export default class AtMention extends PureComponent { defaultChannel: PropTypes.object, inChannel: PropTypes.array, isSearch: PropTypes.bool, - listHeight: PropTypes.number, matchTerm: PropTypes.string, + maxListHeight: PropTypes.number, onChangeText: PropTypes.func.isRequired, onResultCountChange: PropTypes.func.isRequired, outChannel: PropTypes.array, @@ -204,7 +204,7 @@ export default class AtMention extends PureComponent { }; render() { - const {isSearch, listHeight, theme} = this.props; + const {maxListHeight, theme} = this.props; const {mentionComplete, sections} = this.state; if (sections.length === 0 || mentionComplete) { @@ -219,7 +219,7 @@ export default class AtMention extends PureComponent { { listView: { backgroundColor: theme.centerChannelBg, }, - search: { - minHeight: 125, - }, }; }); diff --git a/app/components/autocomplete/autocomplete.js b/app/components/autocomplete/autocomplete.js index 587a2652c..d67b5b383 100644 --- a/app/components/autocomplete/autocomplete.js +++ b/app/components/autocomplete/autocomplete.js @@ -23,6 +23,7 @@ export default class Autocomplete extends PureComponent { cursorPosition: PropTypes.number.isRequired, deviceHeight: PropTypes.number, onChangeText: PropTypes.func.isRequired, + maxHeight: PropTypes.number, rootId: PropTypes.string, isSearch: PropTypes.bool, theme: PropTypes.object.isRequired, @@ -84,12 +85,21 @@ export default class Autocomplete extends PureComponent { this.setState({keyboardOffset: 0}); }; - listHeight() { - let offset = Platform.select({ios: 65, android: 75}); - if (DeviceInfo.getModel().includes('iPhone X')) { - offset = 90; + maxListHeight() { + let maxHeight; + if (this.props.maxHeight) { + maxHeight = this.props.maxHeight; + } else { + // List is expanding downwards, likely from the search box + let offset = Platform.select({ios: 65, android: 75}); + if (DeviceInfo.getModel().includes('iPhone X')) { + offset = 90; + } + + maxHeight = this.props.deviceHeight - offset - this.state.keyboardOffset; } - return this.props.deviceHeight - offset - this.state.keyboardOffset; + + return maxHeight; } render() { @@ -113,26 +123,29 @@ export default class Autocomplete extends PureComponent { containerStyle.push(style.borders); } } - const listHeight = this.listHeight(); + + const maxListHeight = this.maxListHeight(); return ( @@ -167,7 +180,6 @@ const getStyleFromTheme = makeStyleSheetFromTheme((theme) => { }, container: { bottom: 0, - maxHeight: 200, }, content: { flex: 1, diff --git a/app/components/autocomplete/channel_mention/channel_mention.js b/app/components/autocomplete/channel_mention/channel_mention.js index 1d718017a..e6146fcd3 100644 --- a/app/components/autocomplete/channel_mention/channel_mention.js +++ b/app/components/autocomplete/channel_mention/channel_mention.js @@ -25,8 +25,8 @@ export default class ChannelMention extends PureComponent { currentTeamId: PropTypes.string.isRequired, cursorPosition: PropTypes.number.isRequired, isSearch: PropTypes.bool, - listHeight: PropTypes.number, matchTerm: PropTypes.string, + maxListHeight: PropTypes.number, myChannels: PropTypes.array, myMembers: PropTypes.object, otherChannels: PropTypes.array, @@ -194,7 +194,7 @@ export default class ChannelMention extends PureComponent { }; render() { - const {isSearch, listHeight, theme} = this.props; + const {maxListHeight, theme} = this.props; const {mentionComplete, sections} = this.state; if (sections.length === 0 || mentionComplete) { @@ -209,7 +209,7 @@ export default class ChannelMention extends PureComponent { { listView: { backgroundColor: theme.centerChannelBg, }, - search: { - minHeight: 125, - }, }; }); diff --git a/app/components/autocomplete/date_suggestion/date_suggestion.js b/app/components/autocomplete/date_suggestion/date_suggestion.js index 2b05e8e9c..47216e99d 100644 --- a/app/components/autocomplete/date_suggestion/date_suggestion.js +++ b/app/components/autocomplete/date_suggestion/date_suggestion.js @@ -15,7 +15,6 @@ import {changeOpacity} from 'app/utils/theme'; export default class DateSuggestion extends PureComponent { static propTypes = { cursorPosition: PropTypes.number.isRequired, - listHeight: PropTypes.number, locale: PropTypes.string.isRequired, matchTerm: PropTypes.string, onChangeText: PropTypes.func.isRequired, diff --git a/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js b/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js index 9c11c2e11..96f4805e4 100644 --- a/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js +++ b/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js @@ -29,6 +29,7 @@ export default class EmojiSuggestion extends Component { emojis: PropTypes.array.isRequired, isSearch: PropTypes.bool, fuse: PropTypes.object.isRequired, + maxListHeight: PropTypes.number, theme: PropTypes.object.isRequired, onChangeText: PropTypes.func.isRequired, onResultCountChange: PropTypes.func.isRequired, @@ -171,18 +172,20 @@ export default class EmojiSuggestion extends Component { getItemLayout = ({index}) => ({length: 40, offset: 40 * index, index}) render() { + const {maxListHeight, theme} = this.props; + if (!this.state.active) { // If we are not in an active state return null so nothing is rendered // other components are not blocked. return null; } - const style = getStyleFromTheme(this.props.theme); + const style = getStyleFromTheme(theme); return ( { - this.autocomplete = c; - }; - blur = () => { if (this.refs.input) { this.refs.input.blur(); @@ -487,6 +487,12 @@ export default class PostTextbox extends PureComponent { ); }; + handleLayout = (e) => { + this.setState({ + top: e.nativeEvent.layout.y, + }); + }; + render() { const {intl} = this.context; const { @@ -514,7 +520,13 @@ export default class PostTextbox extends PureComponent { ); } - const {contentHeight, cursorPosition, showFileMaxWarning, value} = this.state; + const { + contentHeight, + cursorPosition, + showFileMaxWarning, + top, + value, + } = this.state; const textInputHeight = Math.min(contentHeight, MAX_CONTENT_HEIGHT); const textValue = channelIsLoading ? '' : value; @@ -547,48 +559,52 @@ export default class PostTextbox extends PureComponent { } return ( - + - {!channelIsArchived && - {!channelIsReadOnly && attachmentButton} - - - {this.renderSendButton()} + {!channelIsArchived && ( + + {!channelIsReadOnly && attachmentButton} + + + {this.renderSendButton()} + - } + )} {channelIsArchived && this.archivedView(theme, style)} - + ); } }