Skip to content

Commit 0f3ad1b

Browse files
committed
chore: Default Combobox do not enable filterOption
1 parent 43e7e1f commit 0f3ad1b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/Select.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ const Select = React.forwardRef(
229229
const multiple = isMultiple(mode);
230230
const childrenAsData = !!(!options && children);
231231

232+
const mergedFilterOption = React.useMemo(() => {
233+
if (filterOption === undefined && mode === 'combobox') {
234+
return false;
235+
}
236+
return filterOption;
237+
}, [filterOption, mode]);
238+
232239
// ========================= FieldNames =========================
233240
const mergedFieldNames = React.useMemo(
234241
() => fillFieldNames(fieldNames, childrenAsData),
@@ -396,7 +403,7 @@ const Select = React.forwardRef(
396403
filledTagOptions,
397404
mergedFieldNames,
398405
mergedSearchValue,
399-
filterOption,
406+
mergedFilterOption,
400407
optionFilterProp,
401408
);
402409

tests/Combobox.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,4 +485,26 @@ describe('Select.Combobox', () => {
485485
wrapper.find('input').simulate('compositionEnd', { target: { value: '啊' } });
486486
expect(onChange).toHaveBeenCalledTimes(2);
487487
});
488+
489+
it('default filterOption is false', () => {
490+
const wrapper = mount(
491+
<Select
492+
mode="combobox"
493+
open
494+
searchValue="not exist"
495+
options={[
496+
{
497+
label: 'Light',
498+
value: 'light',
499+
},
500+
{
501+
label: 'Bamboo',
502+
value: 'bamboo',
503+
},
504+
]}
505+
/>,
506+
);
507+
508+
expect(wrapper.find('List').prop('data')).toHaveLength(2);
509+
});
488510
});

0 commit comments

Comments
 (0)