File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 * under the License.
1818 */
1919
20- import React , { useCallback , useEffect , useState } from 'react' ;
20+ import React , { useCallback , useState } from 'react' ;
2121import {
2222 EuiFlexGroup ,
2323 EuiFlexItem ,
@@ -28,6 +28,8 @@ import {
2828} from '@elastic/eui' ;
2929import { FormattedMessage } from '@kbn/i18n/react' ;
3030import { i18n } from '@kbn/i18n' ;
31+ import { useDebounce } from 'react-use' ;
32+
3133import { Vis } from 'ui/vis' ;
3234import { discardChanges , EditorAction } from './state' ;
3335
@@ -53,11 +55,15 @@ function DefaultEditorControls({
5355 const toggleAutoApply = useCallback ( e => setAutoApplyEnabled ( e . target . checked ) , [ ] ) ;
5456 const onClickDiscard = useCallback ( ( ) => dispatch ( discardChanges ( vis ) ) , [ dispatch , vis ] ) ;
5557
56- useEffect ( ( ) => {
57- if ( autoApplyEnabled && isDirty ) {
58- applyChanges ( ) ;
59- }
60- } , [ isDirty , autoApplyEnabled , applyChanges ] ) ;
58+ useDebounce (
59+ ( ) => {
60+ if ( autoApplyEnabled && isDirty ) {
61+ applyChanges ( ) ;
62+ }
63+ } ,
64+ 300 ,
65+ [ isDirty , autoApplyEnabled , applyChanges ]
66+ ) ;
6167
6268 return (
6369 < div className = "visEditorSidebar__controls" >
You can’t perform that action at this time.
0 commit comments