Skip to content

Commit 6d44fba

Browse files
committed
autocomplete: Show popup only when the input is focused.
Before this change, if you have an autocomplete popup visible for the message TextInput and then move focus to the topic TextInput, the first popup stays visible; so you can even wind up with *two* autocompletion popups (one for message, one for topic) visible at the same time. Solve that the same way we do for TopicAutocomplete.
1 parent c4269f5 commit 6d44fba

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/autocomplete/AutocompleteView.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const prefixToComponent = {
1616
};
1717

1818
type Props = {|
19+
isFocused: boolean,
1920
text: string,
2021
selection: InputSelectionType,
2122
onAutocomplete: (input: string) => void,
@@ -29,10 +30,10 @@ export default class AutocompleteView extends PureComponent<Props> {
2930
};
3031

3132
render() {
32-
const { text, selection } = this.props;
33+
const { isFocused, text, selection } = this.props;
3334
const { lastWordPrefix, filter } = getAutocompleteFilter(text, selection);
3435
const AutocompleteComponent = prefixToComponent[lastWordPrefix];
35-
const shouldShow = !!AutocompleteComponent && filter.length > 0;
36+
const shouldShow = isFocused && !!AutocompleteComponent && filter.length > 0;
3637

3738
return (
3839
<AnimatedScaleComponent visible={shouldShow}>

src/compose/ComposeBox.js

+1
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class ComposeBox extends PureComponent<Props, State> {
333333
onAutocomplete={this.handleTopicAutocomplete}
334334
/>
335335
<AutocompleteView
336+
isFocused={this.state.isMessageFocused}
336337
selection={selection}
337338
text={message}
338339
onAutocomplete={this.handleMessageAutocomplete}

0 commit comments

Comments
 (0)