Skip to content

Commit 4e4700c

Browse files
authored
fix: Keep multiple select open on clear (#1225)
1 parent 7876c6c commit 4e4700c

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/SelectInput/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
200200
if (!shouldPreventClose) {
201201
toggleOpen();
202202
}
203-
} else if (triggerOpen) {
204-
// Lazy should also close when click clear icon
203+
} else if (triggerOpen && !multiple) {
204+
// Lazy should also close when click clear icon in single select.
205205
toggleOpen(false);
206206
}
207207
}

tests/Multiple.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,27 @@ describe('Select.Multiple', () => {
108108
expect(container.querySelector('input').value).toBe('');
109109
});
110110

111+
it('keeps popup open when clearing values', () => {
112+
const onPopupVisibleChange = jest.fn();
113+
const { container } = render(
114+
<Select
115+
mode="multiple"
116+
defaultOpen
117+
defaultValue={['1', '2']}
118+
allowClear
119+
onPopupVisibleChange={onPopupVisibleChange}
120+
>
121+
<Option value="1">One</Option>
122+
<Option value="2">Two</Option>
123+
</Select>,
124+
);
125+
126+
fireEvent.mouseDown(container.querySelector('.rc-select-clear'));
127+
128+
expectOpen(container, true);
129+
expect(onPopupVisibleChange).not.toHaveBeenCalledWith(false);
130+
});
131+
111132
it('tokenize input when mode=tags and open=false', () => {
112133
const handleChange = jest.fn();
113134
const handleSelect = jest.fn();

0 commit comments

Comments
 (0)