Skip to content

Commit

Permalink
[TSVB] Fields lists do not populate all the times (elastic#85530)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Dec 14, 2020
1 parent a22b397 commit 61042e1
Showing 1 changed file with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,26 @@ export class VisEditor extends Component {
this.props.eventEmitter.emit('dirtyStateChange', {
isDirty: false,
});

const extractedIndexPatterns = extractIndexPatterns(this.state.model);
if (!isEqual(this.state.extractedIndexPatterns, extractedIndexPatterns)) {
this.abortableFetchFields(extractedIndexPatterns).then((visFields) => {
this.setState({
visFields,
extractedIndexPatterns,
});
});
}
}, VIS_STATE_DEBOUNCE_DELAY);

debouncedFetchFields = debounce(
(extractedIndexPatterns) => {
if (this.abortControllerFetchFields) {
this.abortControllerFetchFields.abort();
}
this.abortControllerFetchFields = new AbortController();
abortableFetchFields = (extractedIndexPatterns) => {
if (this.abortControllerFetchFields) {
this.abortControllerFetchFields.abort();
}
this.abortControllerFetchFields = new AbortController();

return fetchFields(extractedIndexPatterns, this.abortControllerFetchFields.signal);
},
VIS_STATE_DEBOUNCE_DELAY,
{ leading: true }
);
return fetchFields(extractedIndexPatterns, this.abortControllerFetchFields.signal);
};

handleChange = (partialModel) => {
if (isEmpty(partialModel)) {
Expand All @@ -105,16 +111,6 @@ export class VisEditor extends Component {
dirty = false;
}

const extractedIndexPatterns = extractIndexPatterns(nextModel);
if (!isEqual(this.state.extractedIndexPatterns, extractedIndexPatterns)) {
this.debouncedFetchFields(extractedIndexPatterns).then((visFields) =>
this.setState({
visFields,
extractedIndexPatterns,
})
);
}

this.setState({
dirty,
model: nextModel,
Expand Down

0 comments on commit 61042e1

Please sign in to comment.