mirror of
https://github.com/apache/superset.git
synced 2026-04-18 07:35:09 +00:00
[sql lab]Add autoSelect (#2713)
In sql editor database dropdown list, we want to auto-select the first available option.
This commit is contained in:
committed by
Maxime Beauchemin
parent
cb14640a82
commit
fffb7b500a
@@ -11,6 +11,7 @@ const propTypes = {
|
||||
value: PropTypes.number,
|
||||
valueRenderer: PropTypes.func,
|
||||
placeholder: PropTypes.string,
|
||||
autoSelect: PropTypes.bool,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
@@ -37,6 +38,10 @@ class AsyncSelect extends React.PureComponent {
|
||||
const mutator = this.props.mutator;
|
||||
$.get(this.props.dataEndpoint, (data) => {
|
||||
this.setState({ options: mutator ? mutator(data) : data, isLoading: false });
|
||||
|
||||
if (this.props.autoSelect && this.state.options.length) {
|
||||
this.onChange(this.state.options[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user