InfluxDB: InfluxQL: apply on enter not on blur (#34963)

This commit is contained in:
Gábor Farkas 2021-05-31 10:09:29 +02:00 committed by GitHub
parent e38c6d73a0
commit 618dc6a2f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,22 +137,23 @@ const Sel = ({ loadOptions, filterByLoadOptions, allowCustomValue, onChange, onC
type InpProps = {
initialValue: string;
onChange: (newVal: string) => void;
onClose: () => void;
};
const Inp = ({ initialValue, onChange }: InpProps): JSX.Element => {
const Inp = ({ initialValue, onChange, onClose }: InpProps): JSX.Element => {
const [currentValue, setCurrentValue] = useShadowedState(initialValue);
const onBlur = () => {
// we send empty-string as undefined
onChange(currentValue);
};
return (
<Input
autoFocus
type="text"
spellCheck={false}
onBlur={onBlur}
onBlur={onClose}
onKeyDown={(e) => {
if (e.key === 'Enter') {
onChange(currentValue);
}
}}
onChange={(e) => {
setCurrentValue(e.currentTarget.value);
}}
@ -208,6 +209,9 @@ export const Seg = ({
return (
<Inp
initialValue={value}
onClose={() => {
setOpen(false);
}}
onChange={(v) => {
setOpen(false);
onChange({ value: v, label: v });