Skip to content

Commit cc00ba6

Browse files
author
刘欢
committed
fix: Remove tokenSeparators from showSearch
1 parent ba17f53 commit cc00ba6

File tree

4 files changed

+5
-16
lines changed

4 files changed

+5
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export default () => (
8585
| dropdownAlign | additional align applied to dropdown | [AlignType](https://github.com/react-component/trigger/blob/728d7e92394aa4b3214650f743fc47e1382dfa68/src/interface.ts#L25-L80) | {} |
8686
| dropdownMenuStyle | additional style applied to dropdown menu | Object | React.CSSProperties |
8787
| notFoundContent | specify content to show when no result matches. | ReactNode | 'Not Found' |
88+
| tokenSeparators | separator used to tokenize on tag/multiple mode | string[]? | |
8889
| open | control select open | boolean | |
8990
| defaultOpen | control select default open | boolean | |
9091
| placeholder | select placeholder | React Node | |
@@ -140,11 +141,10 @@ export default () => (
140141
| name | description | type | default |
141142
| --- | --- | --- | --- |
142143
| autoClearSearchValue | auto clear search input value when multiple select is selected/deselected | boolean | true |
143-
| filterOption | whether filter options by input value. default filter by option's optionFilterProp prop's value | boolean | true/Function(inputValue:string, option:Option) |
144+
| filterOption | whether filter options by input value. default filter by option's optionFilterProp prop's value | boolean\| (inputValue: string, option: Option) => boolean | true |
144145
| filterSort | Sort function for search options sorting, see [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)'s compareFunction. | Function(optionA:Option, optionB: Option) | - |
145146
| optionFilterProp | which prop value of option will be used for filter if filterOption is true | String | 'value' |
146147
| searchValue | The current input "search" text | string | - |
147-
| tokenSeparators | separator used to tokenize on tag/multiple mode | string[]? | |
148148
| onSearch | called when input changed | function | - |
149149

150150
### Option props

src/Select.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ export interface SearchConfig<OptionType> {
115115
searchValue?: string;
116116
autoClearSearchValue?: boolean;
117117
onSearch?: (value: string) => void;
118-
tokenSeparators?: string[];
119118
filterOption?: boolean | FilterFunc<OptionType>;
120119
filterSort?: (optionA: OptionType, optionB: OptionType, info: { searchValue: string }) => number;
121120
optionFilterProp?: string;
@@ -142,7 +141,6 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
142141

143142
/** @deprecated pleace use SearchConfig.onSearch */
144143
onSearch?: SearchConfig<OptionType>['onSearch'];
145-
/** @deprecated pleace use SearchConfig.tokenSeparators */
146144
tokenSeparators?: string[];
147145
// >>> Options
148146
/**
@@ -234,7 +232,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
234232
filterSort,
235233
onSearch,
236234
autoClearSearchValue = true,
237-
tokenSeparators,
238235
} = searchConfig;
239236

240237
const mergedId = useId(id);
@@ -724,7 +721,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
724721
onSearch={onInternalSearch}
725722
autoClearSearchValue={autoClearSearchValue}
726723
onSearchSplit={onInternalSearchSplit}
727-
tokenSeparators={tokenSeparators}
728724
popupMatchSelectWidth={popupMatchSelectWidth}
729725
// >>> OptionList
730726
OptionList={OptionList}

src/hooks/useSearchConfig.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const legacySearchProps = [
77
'filterSort',
88
'onSearch',
99
'autoClearSearchValue',
10-
'tokenSeparators',
1110
];
1211
// Convert `showSearch` to unique config
1312
export default function useSearchConfig(
@@ -21,7 +20,6 @@ export default function useSearchConfig(
2120
filterSort,
2221
onSearch,
2322
autoClearSearchValue,
24-
tokenSeparators,
2523
} = props || {};
2624
return React.useMemo<[boolean | undefined, SearchConfig<DefaultOptionType>]>(() => {
2725
const legacyShowSearch: SearchConfig<DefaultOptionType> = {};
@@ -46,6 +44,5 @@ export default function useSearchConfig(
4644
filterSort,
4745
onSearch,
4846
autoClearSearchValue,
49-
tokenSeparators,
5047
]);
5148
}

tests/Select.test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,14 +2630,14 @@ describe('Select.Basic', () => {
26302630
expect(items[0].title).toBe('12');
26312631
expect(items[2].title).toBe('12');
26322632
});
2633-
it('autoClearSearchValue,tokenSeparators', () => {
2633+
it('autoClearSearchValue', () => {
26342634
const { container } = render(
26352635
<>
26362636
<div id="test1">
2637-
<LegacyDemo showSearch autoClearSearchValue={false} tokenSeparators={[',', '*']} />
2637+
<LegacyDemo showSearch autoClearSearchValue={false} />
26382638
</div>
26392639
<div id="test2">
2640-
<CurrentDemo autoClearSearchValue={false} tokenSeparators={[',', '*']} />
2640+
<CurrentDemo autoClearSearchValue={false} />
26412641
</div>
26422642
</>,
26432643
);
@@ -2652,10 +2652,6 @@ describe('Select.Basic', () => {
26522652
fireEvent.click(items[1]);
26532653
expect(legacyInput).toHaveValue('a');
26542654
expect(currentInput).toHaveValue('a');
2655-
fireEvent.change(legacyInput, { target: { value: '1,' } });
2656-
fireEvent.change(currentInput, { target: { value: '1,' } });
2657-
expect(legacyInput).toHaveValue('');
2658-
expect(currentInput).toHaveValue('');
26592655
});
26602656
});
26612657
});

0 commit comments

Comments
 (0)