Skip to content

Commit ba17f53

Browse files
author
刘欢
committed
fix: Remove optionLabelProp from showSearch
1 parent 07c4c5a commit ba17f53

File tree

4 files changed

+4
-27
lines changed

4 files changed

+4
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export default () => (
9898
| combobox | enable combobox mode(can not set multiple at the same time) | boolean | false |
9999
| multiple | whether multiple select | boolean | false |
100100
| disabled | whether disabled select | boolean | false |
101+
| optionLabelProp | render option value or option children as content of select | String: 'value'/'children' | 'value' |
101102
| defaultValue | initial selected option(s) | String \| String[] | - |
102103
| value | current selected option(s) | String \| String[] \| {key:String, label:React.Node} \| {key:String, label:React.Node}[] | - |
103104
| labelInValue | whether to embed label in value, see above value type. Not support `combobox` mode | boolean | false |
@@ -142,7 +143,6 @@ export default () => (
142143
| filterOption | whether filter options by input value. default filter by option's optionFilterProp prop's value | boolean | true/Function(inputValue:string, option:Option) |
143144
| 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) | - |
144145
| optionFilterProp | which prop value of option will be used for filter if filterOption is true | String | 'value' |
145-
| optionLabelProp | render option value or option children as content of select | String: 'value'/'children' | 'value' |
146146
| searchValue | The current input "search" text | string | - |
147147
| tokenSeparators | separator used to tokenize on tag/multiple mode | string[]? | |
148148
| onSearch | called when input changed | function | - |

src/Select.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ export interface SearchConfig<OptionType> {
119119
filterOption?: boolean | FilterFunc<OptionType>;
120120
filterSort?: (optionA: OptionType, optionB: OptionType, info: { searchValue: string }) => number;
121121
optionFilterProp?: string;
122-
optionLabelProp?: string;
123122
}
124123
export interface SelectProps<ValueType = any, OptionType extends BaseOptionType = DefaultOptionType>
125124
extends Omit<BaseSelectPropsWithoutPrivate, 'showSearch'> {
@@ -157,7 +156,6 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
157156
filterSort?: SearchConfig<OptionType>['filterSort'];
158157
/** @deprecated pleace use SearchConfig.optionFilterProp */
159158
optionFilterProp?: string;
160-
/** @deprecated pleace use SearchConfig.optionLabelProp */
161159
optionLabelProp?: string;
162160

163161
children?: React.ReactNode;
@@ -205,6 +203,7 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
205203
onDeselect,
206204
onActive,
207205
popupMatchSelectWidth = true,
206+
optionLabelProp,
208207
options,
209208
optionRender,
210209
children,
@@ -232,7 +231,6 @@ const Select = React.forwardRef<BaseSelectRef, SelectProps<any, DefaultOptionTyp
232231
filterOption,
233232
searchValue,
234233
optionFilterProp,
235-
optionLabelProp,
236234
filterSort,
237235
onSearch,
238236
autoClearSearchValue = true,

src/hooks/useSearchConfig.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const legacySearchProps = [
44
'filterOption',
55
'searchValue',
66
'optionFilterProp',
7-
'optionLabelProp',
87
'filterSort',
98
'onSearch',
109
'autoClearSearchValue',
@@ -19,7 +18,6 @@ export default function useSearchConfig(
1918
filterOption,
2019
searchValue,
2120
optionFilterProp,
22-
optionLabelProp,
2321
filterSort,
2422
onSearch,
2523
autoClearSearchValue,
@@ -45,7 +43,6 @@ export default function useSearchConfig(
4543
filterOption,
4644
searchValue,
4745
optionFilterProp,
48-
optionLabelProp,
4946
filterSort,
5047
onSearch,
5148
autoClearSearchValue,

tests/Select.test.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,23 +2521,7 @@ describe('Select.Basic', () => {
25212521
expect(input).toHaveClass(customClassNames.input);
25222522
expect(input).toHaveStyle(customStyle.input);
25232523
});
2524-
// searchValue?: string;
2525-
// autoClearSearchValue?: boolean;
2526-
// onSearch?: (value: string) => void;
2527-
// tokenSeparators?: string[];
2528-
// filterOption?: boolean | FilterFunc<OptionType>;
2529-
// filterSort?: (optionA: OptionType, optionB: OptionType, info: { searchValue: string }) => number;
2530-
// optionFilterProp?: string;
2531-
// optionLabelProp?: string;
2532-
// const props = {
2533-
// searchValue: '1',
2534-
// autoClearSearchValue: false,
2535-
// filterSort: (optionA, optionB) => {
2536-
// return Number(optionB.value) - Number(optionA.value);
2537-
// },
2538-
// optionFilterProp: 'label',
2539-
// optionLabelProp: 'value',
2540-
// };
2524+
25412525
describe('combine showSearch', () => {
25422526
let errorSpy;
25432527

@@ -2617,7 +2601,7 @@ describe('Select.Basic', () => {
26172601
expect(currentInput).toHaveValue('1');
26182602
expect(legacyInput.value).toBe(currentInput.value);
26192603
});
2620-
it('option:sort,FilterProp,LabelProp ', () => {
2604+
it('option:sort,FilterProp ', () => {
26212605
const { container } = render(
26222606
<>
26232607
<div id="test1">
@@ -2628,7 +2612,6 @@ describe('Select.Basic', () => {
26282612
return Number(b.label) - Number(a.label);
26292613
}}
26302614
optionFilterProp="label"
2631-
optionLabelProp="value"
26322615
/>
26332616
</div>
26342617
<div id="test2">
@@ -2638,7 +2621,6 @@ describe('Select.Basic', () => {
26382621
return Number(b.label) - Number(a.label);
26392622
}}
26402623
optionFilterProp="label"
2641-
optionLabelProp="value"
26422624
/>
26432625
</div>
26442626
</>,

0 commit comments

Comments
 (0)