Skip to content

Commit

Permalink
fix label input debouncing
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Nov 23, 2020
1 parent 10afcf0 commit f481c36
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 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 @@ -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 f481c36

Please sign in to comment.