Merge branch 'master' of https://github.com/2betop/amis
This commit is contained in:
commit
63d97bc511
|
@ -400,16 +400,37 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|||
loadOptions && loadOptions('');
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps: SelectProps) {
|
||||
componentDidUpdate(prevProps: SelectProps) {
|
||||
const props = this.props;
|
||||
let fn:() => void = noop;
|
||||
|
||||
if (
|
||||
props.value !== nextProps.value ||
|
||||
JSON.stringify(props.options) !== JSON.stringify(nextProps.options)
|
||||
props.value !== prevProps.value ||
|
||||
JSON.stringify(props.options) !== JSON.stringify(prevProps.options)
|
||||
) {
|
||||
let selection: Array<Option>;
|
||||
if (
|
||||
(
|
||||
!prevProps.options
|
||||
|| !prevProps.options.length
|
||||
)
|
||||
&& props.options.length
|
||||
) {
|
||||
const {selection: stateSelection} = this.state;
|
||||
const {multiple, defaultCheckAll, options, onChange, simpleValue} = props;
|
||||
if (multiple && defaultCheckAll && options.length) {
|
||||
selection = union(options, stateSelection);
|
||||
fn = () => onChange(simpleValue ? selection.map(item => item.value) : selection);
|
||||
} else {
|
||||
selection = value2array(props.value, props);
|
||||
}
|
||||
} else {
|
||||
selection = value2array(props.value, props);
|
||||
}
|
||||
|
||||
this.setState({
|
||||
selection: value2array(nextProps.value, nextProps)
|
||||
});
|
||||
selection: selection
|
||||
}, fn);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue