mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
[explore] fix empty chart when changing viz type (#2698)
* [explore] fix empty chart when changing viz type * Lint
This commit is contained in:
committed by
GitHub
parent
3cd16cf368
commit
3e7b5df287
@@ -60,6 +60,7 @@ class ChartContainer extends React.PureComponent {
|
||||
) && !this.props.queryResponse.error
|
||||
&& this.props.chartStatus !== 'failed'
|
||||
&& this.props.chartStatus !== 'stopped'
|
||||
&& this.props.chartStatus !== 'loading'
|
||||
) {
|
||||
this.renderViz();
|
||||
}
|
||||
|
||||
@@ -51,17 +51,26 @@ export default class Control extends React.PureComponent {
|
||||
super(props);
|
||||
this.validate = this.validate.bind(this);
|
||||
this.onChange = this.onChange.bind(this);
|
||||
this.validateAndSetValue(props.value, []);
|
||||
}
|
||||
componentDidMount() {
|
||||
this.validateAndSetValue(this.props.value, []);
|
||||
}
|
||||
onChange(value, errors) {
|
||||
this.validateAndSetValue(value, errors);
|
||||
}
|
||||
validateAndSetValue(value, errors) {
|
||||
let validationErrors = this.validate(value);
|
||||
let validationErrors = this.props.validationErrors;
|
||||
let currentErrors = this.validate(value);
|
||||
if (errors && errors.length > 0) {
|
||||
validationErrors = validationErrors.concat(errors);
|
||||
currentErrors = validationErrors.concat(errors);
|
||||
}
|
||||
if (validationErrors.length + currentErrors.length > 0) {
|
||||
validationErrors = currentErrors;
|
||||
}
|
||||
|
||||
if (value !== this.props.value || validationErrors !== this.props.validationErrors) {
|
||||
this.props.actions.setControlValue(this.props.name, value, validationErrors);
|
||||
}
|
||||
this.props.actions.setControlValue(this.props.name, value, validationErrors);
|
||||
}
|
||||
validate(value) {
|
||||
const validators = this.props.validators;
|
||||
|
||||
@@ -39,6 +39,7 @@ const bootstrappedState = Object.assign(
|
||||
queryResponse: null,
|
||||
triggerQuery: true,
|
||||
triggerRender: false,
|
||||
alert: null,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ export function getControlsState(state, form_data) {
|
||||
if (typeof control.default === 'function') {
|
||||
control.default = control.default(control);
|
||||
}
|
||||
control.validationErrors = [];
|
||||
control.value = formData[k] !== undefined ? formData[k] : control.default;
|
||||
controlsState[k] = control;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user