Skip to content

Commit

Permalink
fix(Select): fix valueDisplay onclose callback
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Oct 22, 2024
1 parent 4c70727 commit 1519e25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/select/_example/custom-selected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,19 @@ const CustomSelected = () => {
{ label: '选项八', value: '8' },
{ label: '选项九', value: '9' },
]}
valueDisplay={({ value }) =>
Array.isArray(value) && value.length > 0 ? value.map((v, idx) => <Tag key={idx}>{`${v}选项`}</Tag>) : null
valueDisplay={({ value, onClose }) =>
Array.isArray(value) && value.length > 0
? value.map((v: string, idx: number) => (
<Tag
key={idx}
onClose={(context) => {
context.e && context.e.stopPropagation();
onClose(idx);
}}
closable
>{`${v}选项`}</Tag>
))
: null
}
/>
</Space>
Expand Down
2 changes: 1 addition & 1 deletion src/select/base/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const Select = forwardRefWithStatics(
}

if (trigger === 'tag-remove') {
e.stopPropagation();
e?.stopPropagation?.();
const values = getSelectValueArr(value, value[index], true, valueType, keys);
// 处理onChange回调中的selectedOptions参数
const currentSelectedOptions = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions);
Expand Down

0 comments on commit 1519e25

Please sign in to comment.