Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ const Cascader = React.forwardRef<CascaderRef, InternalCascaderProps>((props, re

// =========================== Select ===========================
const onInternalSelect = useRefFunc((valuePath: SingleValueType) => {
setSearchValue('');
if (!multiple) {
triggerChange(valuePath);
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/OptionList/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export default function Column({
triggerOpenPath();
}
}}
onMouseDown={e => {
// Prevent selector from blurring
e.preventDefault();
}}
>
{multiple && (
<Checkbox
Expand Down
11 changes: 11 additions & 0 deletions tests/search.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,15 @@ describe('Cascader.Search', () => {

errorSpy.mockRestore();
});

it('onChange should be triggered when click option with multiple', () => {
const onChange = jest.fn();
const wrapper = mount(
<Cascader checkable options={options} changeOnSelect onChange={onChange} showSearch />,
);
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());
});
});