Commit 4c689fce by Torkel Ödegaard Committed by GitHub

Merge pull request #15121 from grafana/davkal/15011-fix-query-change-twice

Explore: query field should not propagate non-text change
parents a747023b 8d44ed8d
......@@ -128,17 +128,21 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
}
onChange = ({ value }) => {
const textChanged = value.document !== this.state.value.document;
const documentChanged = value.document !== this.state.value.document;
const prevValue = this.state.value;
// Control editor loop, then pass text change up to parent
this.setState({ value }, () => {
if (textChanged) {
this.handleChangeValue();
if (documentChanged) {
const textChanged = Plain.serialize(prevValue) !== Plain.serialize(value);
if (textChanged) {
this.handleChangeValue();
}
}
});
// Show suggest menu on text input
if (textChanged && value.selection.isCollapsed) {
if (documentChanged && value.selection.isCollapsed) {
// Need one paint to allow DOM-based typeahead rules to work
window.requestAnimationFrame(this.handleTypeahead);
} else if (!this.resetTimer) {
......
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