@@ -74,20 +74,26 @@ export class VisEditor extends Component {
7474 this . props . eventEmitter . emit ( 'dirtyStateChange' , {
7575 isDirty : false ,
7676 } ) ;
77+
78+ const extractedIndexPatterns = extractIndexPatterns ( this . state . model ) ;
79+ if ( ! isEqual ( this . state . extractedIndexPatterns , extractedIndexPatterns ) ) {
80+ this . abortableFetchFields ( extractedIndexPatterns ) . then ( ( visFields ) => {
81+ this . setState ( {
82+ visFields,
83+ extractedIndexPatterns,
84+ } ) ;
85+ } ) ;
86+ }
7787 } , VIS_STATE_DEBOUNCE_DELAY ) ;
7888
79- debouncedFetchFields = debounce (
80- ( extractedIndexPatterns ) => {
81- if ( this . abortControllerFetchFields ) {
82- this . abortControllerFetchFields . abort ( ) ;
83- }
84- this . abortControllerFetchFields = new AbortController ( ) ;
89+ abortableFetchFields = ( extractedIndexPatterns ) => {
90+ if ( this . abortControllerFetchFields ) {
91+ this . abortControllerFetchFields . abort ( ) ;
92+ }
93+ this . abortControllerFetchFields = new AbortController ( ) ;
8594
86- return fetchFields ( extractedIndexPatterns , this . abortControllerFetchFields . signal ) ;
87- } ,
88- VIS_STATE_DEBOUNCE_DELAY ,
89- { leading : true }
90- ) ;
95+ return fetchFields ( extractedIndexPatterns , this . abortControllerFetchFields . signal ) ;
96+ } ;
9197
9298 handleChange = ( partialModel ) => {
9399 if ( isEmpty ( partialModel ) ) {
@@ -105,16 +111,6 @@ export class VisEditor extends Component {
105111 dirty = false ;
106112 }
107113
108- const extractedIndexPatterns = extractIndexPatterns ( nextModel ) ;
109- if ( ! isEqual ( this . state . extractedIndexPatterns , extractedIndexPatterns ) ) {
110- this . debouncedFetchFields ( extractedIndexPatterns ) . then ( ( visFields ) =>
111- this . setState ( {
112- visFields,
113- extractedIndexPatterns,
114- } )
115- ) ;
116- }
117-
118114 this . setState ( {
119115 dirty,
120116 model : nextModel ,
0 commit comments