Skip to content

Commit

Permalink
fix(select): 修复清空按钮出现时机问题
Browse files Browse the repository at this point in the history
  • Loading branch information
carolin913 committed Feb 10, 2022
1 parent 85017fc commit 2c5c8b1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/select/base/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ const Select = forwardRefWithStatics(
e.preventDefault();
if (!disabled) {
setShowPopup(!showPopup);
setInputVal('');
setInputVal(undefined);
}
};

Expand All @@ -351,7 +351,7 @@ const Select = forwardRefWithStatics(
if (Array.isArray(value)) {
onChange([]);
} else {
onChange('');
onChange(null);
}
setInputVal(undefined);
onClear({ e: event as React.MouseEvent<HTMLDivElement, MouseEvent> });
Expand All @@ -368,7 +368,8 @@ const Select = forwardRefWithStatics(
/>
);
}
if (clearable && value && isHover) {

if (clearable && value !== undefined && value !== null && isHover) {
return (
<CloseCircleFilledIcon
onClick={clearable ? onClearValue : undefined}
Expand Down

0 comments on commit 2c5c8b1

Please sign in to comment.