Skip to content

Commit

Permalink
fix(select): fix onRemove method does not work (#2802)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-ovo authored Mar 15, 2024
1 parent 82fabd3 commit 9b9d6b3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.eslint": "explicit"
},
"cSpell.words": ["activable", "actived", "borderless", "Cascader", "Popconfirm", "Swiper", "tdesign"]
}
20 changes: 18 additions & 2 deletions src/select/_example/multiple.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,24 @@ const MultipleSelect = () => {

return (
<Space breakLine style={{ width: '100%' }}>
<Select value={value} onChange={handleChange} filterable multiple options={options1} />
<Select defaultValue={['1', '2', '3', '4', '5', '6']} placeholder="请选择云产品" multiple>
<Select
value={value}
onChange={handleChange}
filterable
multiple
options={options1}
onRemove={(options) => {
console.log('onRemove', options);
}}
/>
<Select
defaultValue={['1', '2', '3', '4', '5', '6']}
placeholder="请选择云产品"
multiple
onRemove={(options) => {
console.log('onRemove', options);
}}
>
{options2.map((item) => (
<Option value={item.value} label={item.label} key={item.value} content={item.content}></Option>
))}
Expand Down
6 changes: 6 additions & 0 deletions src/select/base/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ const Select = forwardRefWithStatics(
const selectedOptions = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions);
onChange(values, { e, selectedOptions, trigger: 'uncheck' });
tagProps?.onClose?.({ e });

onRemove?.({
value: value[key],
data: { label: v, value: value[key] },
e,
});
}}
>
{v}
Expand Down
2 changes: 1 addition & 1 deletion src/select/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export type SelectValueChangeTrigger = 'clear' | 'tag-remove' | 'backspace' | 'c
export interface SelectRemoveContext<T> {
value: string | number;
data: T;
e: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>;
e: MouseEvent<SVGSVGElement> | KeyboardEvent<HTMLDivElement>;
}

export type SelectOption = TdOptionProps | SelectOptionGroup | PlainObject;
Expand Down

0 comments on commit 9b9d6b3

Please sign in to comment.