Explore: reset typeahead on cursor move

This commit is contained in:
David Kaltschmidt
2018-10-04 17:25:31 +02:00
parent 1a6b0adbd7
commit a0b21db053

View File

@@ -179,15 +179,21 @@ class QueryField extends React.PureComponent<TypeaheadFieldProps, TypeaheadField
}
onChange = ({ value }) => {
const changed = value.document !== this.state.value.document;
const textChanged = value.document !== this.state.value.document;
// Control editor loop, then pass text change up to parent
this.setState({ value }, () => {
if (changed) {
if (textChanged) {
this.handleChangeValue();
}
});
if (changed) {
// Show suggest menu on text input
if (textChanged && value.selection.isCollapsed) {
// Need one paint to allow DOM-based typeahead rules to work
window.requestAnimationFrame(this.handleTypeahead);
} else {
this.resetTypeahead();
}
};