Revert "fix composer jump by reseting lastToken on click and arrow up and down in autosuggesttextarea"

This reverts commit 0b7763e726.
This commit is contained in:
Alex Gleason 2020-09-28 19:06:06 -05:00
parent b78a00a306
commit f71a1e4ce1
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -50,7 +50,6 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
autoFocus: PropTypes.bool, autoFocus: PropTypes.bool,
onFocus: PropTypes.func, onFocus: PropTypes.func,
onBlur: PropTypes.func, onBlur: PropTypes.func,
clickableAreaRef: PropTypes.object,
}; };
static defaultProps = { static defaultProps = {
@ -108,8 +107,6 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
if (suggestions.size > 0 && !suggestionsHidden) { if (suggestions.size > 0 && !suggestionsHidden) {
e.preventDefault(); e.preventDefault();
this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, suggestions.size - 1) }); this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, suggestions.size - 1) });
} else {
this.setState({ lastToken: null });
} }
break; break;
@ -117,8 +114,6 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
if (suggestions.size > 0 && !suggestionsHidden) { if (suggestions.size > 0 && !suggestionsHidden) {
e.preventDefault(); e.preventDefault();
this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, 0) }); this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, 0) });
} else {
this.setState({ lastToken: null });
} }
break; break;
@ -164,28 +159,6 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
this.textarea.focus(); this.textarea.focus();
} }
getClickableArea = () => {
const { clickableAreaRef } = this.props;
return clickableAreaRef ? clickableAreaRef.current : this.form;
}
isClickInside = (e) => {
return [
this.getClickableArea(),
document.querySelector('.autosuggest-textarea__textarea'),
].some(element => element && element.contains(e.target));
}
handleClick = (e) => {
if (this.isClickInside(e)) {
this.setState({ lastToken: null });
}
}
componentDidMount() {
document.addEventListener('click', this.handleClick, true);
}
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const { suggestions } = this.props; const { suggestions } = this.props;
if (suggestions !== prevProps.suggestions && suggestions.size > 0 && prevState.suggestionsHidden && prevState.focused) { if (suggestions !== prevProps.suggestions && suggestions.size > 0 && prevState.suggestionsHidden && prevState.focused) {