mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixed so onBlur event trigger an QueryChange and QueryExecute if values differ
This commit is contained in:
parent
2c255fd85a
commit
3b0a04c627
@ -50,6 +50,7 @@ export interface QueryFieldState {
|
|||||||
typeaheadPrefix: string;
|
typeaheadPrefix: string;
|
||||||
typeaheadText: string;
|
typeaheadText: string;
|
||||||
value: Value;
|
value: Value;
|
||||||
|
lastExecutedValue: Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TypeaheadInput {
|
export interface TypeaheadInput {
|
||||||
@ -89,6 +90,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
|
|||||||
typeaheadPrefix: '',
|
typeaheadPrefix: '',
|
||||||
typeaheadText: '',
|
typeaheadText: '',
|
||||||
value: makeValue(this.placeholdersBuffer.toString(), props.syntax),
|
value: makeValue(this.placeholdersBuffer.toString(), props.syntax),
|
||||||
|
lastExecutedValue: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +169,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
|
|||||||
|
|
||||||
if (onExecuteQuery) {
|
if (onExecuteQuery) {
|
||||||
onExecuteQuery();
|
onExecuteQuery();
|
||||||
|
this.setState({ lastExecutedValue: this.state.value });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -381,12 +384,20 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleBlur = () => {
|
handleBlur = (event, change) => {
|
||||||
|
const { lastExecutedValue } = this.state;
|
||||||
|
const previousValue = lastExecutedValue ? Plain.serialize(this.state.lastExecutedValue) : null;
|
||||||
|
const currentValue = Plain.serialize(change.value);
|
||||||
|
|
||||||
// If we dont wait here, menu clicks wont work because the menu
|
// If we dont wait here, menu clicks wont work because the menu
|
||||||
// will be gone.
|
// will be gone.
|
||||||
this.resetTimer = setTimeout(this.resetTypeahead, 100);
|
this.resetTimer = setTimeout(this.resetTypeahead, 100);
|
||||||
// Disrupting placeholder entry wipes all remaining placeholders needing input
|
// Disrupting placeholder entry wipes all remaining placeholders needing input
|
||||||
this.placeholdersBuffer.clearPlaceholders();
|
this.placeholdersBuffer.clearPlaceholders();
|
||||||
|
|
||||||
|
if (previousValue !== currentValue) {
|
||||||
|
this.executeOnQueryChangeAndExecuteQueries();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleFocus = () => {};
|
handleFocus = () => {};
|
||||||
|
Loading…
Reference in New Issue
Block a user