diff --git a/src/Cascader.tsx b/src/Cascader.tsx index 7eded636..198127c6 100644 --- a/src/Cascader.tsx +++ b/src/Cascader.tsx @@ -331,6 +331,7 @@ const Cascader = React.forwardRef((props, re // =========================== Select =========================== const onInternalSelect = useRefFunc((valuePath: SingleValueType) => { + setSearchValue(''); if (!multiple) { triggerChange(valuePath); } else { diff --git a/src/OptionList/Column.tsx b/src/OptionList/Column.tsx index 9cfdb5cf..7c578660 100644 --- a/src/OptionList/Column.tsx +++ b/src/OptionList/Column.tsx @@ -129,6 +129,10 @@ export default function Column({ triggerOpenPath(); } }} + onMouseDown={e => { + // Prevent selector from blurring + e.preventDefault(); + }} > {multiple && ( { errorSpy.mockRestore(); }); + + it('onChange should be triggered when click option with multiple', () => { + const onChange = jest.fn(); + const wrapper = mount( + , + ); + doSearch(wrapper, 'toy'); + wrapper.find('.rc-cascader-menu-item').first().simulate('click'); + wrapper.find('.rc-cascader-menu-item').first().simulate('mousedown'); + expect(onChange).toHaveBeenCalledWith([['bamboo', 'little', 'fish']], expect.anything()); + }); });