Skip to content

Commit

Permalink
[Lens] Fix label input debouncing (#84121) (#84315)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Nov 25, 2020
1 parent 73c3964 commit 9ecb412
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import './dimension_editor.scss';
import _ from 'lodash';
import React, { useState, useMemo, useEffect } from 'react';
import React, { useState, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import {
EuiListGroup,
Expand Down Expand Up @@ -46,10 +46,6 @@ export interface DimensionEditorProps extends IndexPatternDimensionEditorProps {
const LabelInput = ({ value, onChange }: { value: string; onChange: (value: string) => void }) => {
const [inputValue, setInputValue] = useState(value);

useEffect(() => {
setInputValue(value);
}, [value, setInputValue]);

const onChangeDebounced = useMemo(() => _.debounce(onChange, 256), [onChange]);

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ export const QueryInput = ({
}) => {
const [inputValue, setInputValue] = useState(value);

React.useEffect(() => {
setInputValue(value);
}, [value, setInputValue]);

useDebounce(() => onChange(inputValue), 256, [inputValue]);

const handleInputChange = (input: Query) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useState, useEffect } from 'react';
import React, { useState } from 'react';
import useDebounce from 'react-use/lib/useDebounce';
import { EuiFieldText, keys } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand All @@ -28,10 +28,6 @@ export const LabelInput = ({
}) => {
const [inputValue, setInputValue] = useState(value);

useEffect(() => {
setInputValue(value);
}, [value, setInputValue]);

useDebounce(() => onChange(inputValue), 256, [inputValue]);

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down

0 comments on commit 9ecb412

Please sign in to comment.