Fix metric picker query update

This commit is contained in:
Alexander Zobnin
2022-11-30 14:03:01 +01:00
parent 8aebc649db
commit 14987efae4

View File

@@ -73,6 +73,13 @@ export const MetricPicker = ({ value, options, isLoading, width, onChange }: Pro
onClose(); onClose();
}; };
const onBlurInternal = () => {
if (!isOpen) {
// Only call if menu isn't opened
onChange(query);
}
};
const onKeyDown = (e: React.KeyboardEvent) => { const onKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'ArrowDown') { if (e.key === 'ArrowDown') {
if (!isOpen) { if (!isOpen) {
@@ -105,7 +112,7 @@ export const MetricPicker = ({ value, options, isLoading, width, onChange }: Pro
value={query} value={query}
type="text" type="text"
onChange={onInputChange} onChange={onInputChange}
onBlur={() => onChange(query)} onBlur={onBlurInternal}
onMouseDown={onOpen} onMouseDown={onOpen}
suffix={isLoading && <Spinner />} suffix={isLoading && <Spinner />}
width={width} width={width}