mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: query field should not propagate non-text change
- after mounting with an initial value, the onChange of a query field is triggered - even though the slate documents are not the same, their text values are identical, hence the change propagation is useless - added check to propagate text change only when text has actually changed
This commit is contained in:
parent
a803435b27
commit
8d44ed8d8f
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user