Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(select): fix onRemove method does not work #2802

Merged
merged 1 commit into from
Mar 15, 2024
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
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
Loading