Skip to content

Commit

Permalink
[Lens] Fix empty display name issue in XY chart (elastic#91132)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dej611 and kibanamachine committed Feb 15, 2021
1 parent 957ba15 commit 0bdea91
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const LabelInput = ({ value, onChange }: { value: string; onChange: (value: stri
const [inputValue, setInputValue] = useState(value);
const unflushedChanges = useRef(false);

// Save the initial value
const initialValue = useRef(value);

const onChangeDebounced = useMemo(() => {
const callback = _.debounce((val: string) => {
onChange(val);
Expand All @@ -79,7 +82,7 @@ const LabelInput = ({ value, onChange }: { value: string; onChange: (value: stri
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const val = String(e.target.value);
setInputValue(val);
onChangeDebounced(val);
onChangeDebounced(val || initialValue.current);
};

return (
Expand All @@ -96,6 +99,7 @@ const LabelInput = ({ value, onChange }: { value: string; onChange: (value: stri
data-test-subj="indexPattern-label-edit"
value={inputValue}
onChange={handleInputChange}
placeholder={initialValue.current}
/>
</EuiFormRow>
);
Expand Down

0 comments on commit 0bdea91

Please sign in to comment.