Commit 1da35282 by Torkel Ödegaard Committed by GitHub

Merge pull request #13530 from grafana/davkal/13485-cursor-suggestions

Explore: reset typeahead on cursor move
parents 5aa91fc1 a0b21db0
...@@ -179,15 +179,21 @@ class QueryField extends React.PureComponent<TypeaheadFieldProps, TypeaheadField ...@@ -179,15 +179,21 @@ class QueryField extends React.PureComponent<TypeaheadFieldProps, TypeaheadField
} }
onChange = ({ value }) => { 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 }, () => { this.setState({ value }, () => {
if (changed) { if (textChanged) {
this.handleChangeValue(); 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); window.requestAnimationFrame(this.handleTypeahead);
} else {
this.resetTypeahead();
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment