修复 TreeSelect 单选不可以清除选项的问题

This commit is contained in:
2betop 2020-07-10 13:49:55 +08:00
parent f7dfed9bc3
commit 4c9822c42a
2 changed files with 10 additions and 2 deletions

View File

@ -173,7 +173,9 @@ export class ResultBox extends React.Component<ResultBoxProps> {
{children}
{clearable && !disabled && Array.isArray(result) && result.length ? (
{clearable &&
!disabled &&
(Array.isArray(result) ? result.length : result) ? (
<a
// data-tooltip="清空"
// data-position="bottom"

View File

@ -327,11 +327,17 @@ export default class TreeSelectControl extends React.Component<
extractValue,
delimiter,
valueField,
onChange
onChange,
multiple
} = this.props;
let newValue: any = Array.isArray(value) ? value.concat() : [];
if (!multiple && !newValue.length) {
onChange('');
return;
}
if (joinValues || extractValue) {
newValue = value.map(item => item[valueField || 'value']);
}