修复 picker 内嵌模式选中卡死问题

This commit is contained in:
liaoxuezhi 2019-11-26 16:50:47 +08:00
parent 8de040ac9f
commit bbb431600d
2 changed files with 13 additions and 4 deletions

View File

@ -15,7 +15,8 @@ import {
getScrollParent,
difference,
noop,
autobind
autobind,
isArrayChilrenModified
} from '../utils/helper';
import {resolveVariable} from '../utils/tpl-builtin';
import {
@ -333,7 +334,7 @@ export default class Table extends React.Component<TableProps, object> {
) {
Table.syncRows(store, nextProps, props);
this.syncSelected();
} else if (props.selected !== nextProps.selected) {
} else if (isArrayChilrenModified(props.selected, nextProps.selected)) {
store.updateSelected(nextProps.selected || [], nextProps.valueField);
this.syncSelected();
}

View File

@ -85,6 +85,9 @@ export const FormItemStore = types
return self.errorData.map(item => item.msg);
}
let lastQueryValue: any;
let lastResult: any = [];
return {
get form(): any {
return getForm();
@ -114,8 +117,13 @@ export const FormItemStore = types
},
getSelectedOptions: (value: any = getValue()) => {
if (value === lastQueryValue) {
return lastResult;
}
lastQueryValue = value;
if (typeof value === 'undefined') {
return [];
return (lastResult = []);
}
const selected = Array.isArray(value)
@ -175,7 +183,7 @@ export const FormItemStore = types
unMatched && selectedOptions.push(unMatched);
});
return selectedOptions;
return (lastResult = selectedOptions);
}
};
})