[TSVB] fix not populating fields list if "Auto apply" is off (#96298)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Dmitry Tomashevich 2021-04-15 15:11:16 +03:00 committed by GitHub
parent 1a7095365a
commit 198be4cb8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,19 +97,6 @@ export class VisEditor extends Component<TimeseriesEditorProps, TimeseriesEditor
this.props.eventEmitter.emit('dirtyStateChange', {
isDirty: false,
});
const extractedIndexPatterns = extractIndexPatternValues(
this.state.model,
this.state.defaultIndex
);
if (!isEqual(this.state.extractedIndexPatterns, extractedIndexPatterns)) {
this.abortableFetchFields(extractedIndexPatterns).then((visFields) => {
this.setState({
visFields,
extractedIndexPatterns,
});
});
}
}, VIS_STATE_DEBOUNCE_DELAY);
abortableFetchFields = (extractedIndexPatterns: IndexPatternValue[]) => {
@ -124,10 +111,6 @@ export class VisEditor extends Component<TimeseriesEditorProps, TimeseriesEditor
return;
}
const hasTypeChanged = partialModel.type && this.state.model.type !== partialModel.type;
const nextModel = {
...this.state.model,
...partialModel,
};
let dirty = true;
if (this.state.autoApply || hasTypeChanged) {
this.updateVisState();
@ -135,6 +118,20 @@ export class VisEditor extends Component<TimeseriesEditorProps, TimeseriesEditor
dirty = false;
}
const nextModel = {
...this.state.model,
...partialModel,
};
const extractedIndexPatterns = extractIndexPatternValues(nextModel, this.state.defaultIndex);
if (!isEqual(this.state.extractedIndexPatterns, extractedIndexPatterns)) {
this.abortableFetchFields(extractedIndexPatterns).then((visFields) => {
this.setState({
visFields,
extractedIndexPatterns,
});
});
}
this.setState({
dirty,
model: nextModel,