mirror of
https://github.com/Tencent/tdesign-react.git
synced 2024-10-23 08:33:49 +08:00
fix(Select): fix valueDisplay onClose callback (#3154)
* fix(Select): fix valueDisplay onclose callback * chore: update snapshot --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
4c7072710e
commit
e4e6681a97
@ -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>
|
||||
|
@ -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);
|
||||
|
@ -74469,6 +74469,18 @@ exports[`csr snapshot test > csr test src/select/_example/custom-selected.tsx 1`
|
||||
>
|
||||
选项一选项
|
||||
</span>
|
||||
<svg
|
||||
class="t-icon t-icon-close t-tag__icon-close"
|
||||
fill="none"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M7.05 5.64L12 10.59l4.95-4.95 1.41 1.41L13.41 12l4.95 4.95-1.41 1.41L12 13.41l-4.95 4.95-1.41-1.41L10.59 12 5.64 7.05l1.41-1.41z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div
|
||||
class="t-tag t-tag--default t-tag--dark"
|
||||
@ -74478,6 +74490,18 @@ exports[`csr snapshot test > csr test src/select/_example/custom-selected.tsx 1`
|
||||
>
|
||||
选项二选项
|
||||
</span>
|
||||
<svg
|
||||
class="t-icon t-icon-close t-tag__icon-close"
|
||||
fill="none"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M7.05 5.64L12 10.59l4.95-4.95 1.41 1.41L13.41 12l4.95 4.95-1.41 1.41L12 13.41l-4.95 4.95-1.41-1.41L10.59 12 5.64 7.05l1.41-1.41z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div
|
||||
class="t-tag t-tag--default t-tag--dark"
|
||||
@ -74487,6 +74511,18 @@ exports[`csr snapshot test > csr test src/select/_example/custom-selected.tsx 1`
|
||||
>
|
||||
选项三选项
|
||||
</span>
|
||||
<svg
|
||||
class="t-icon t-icon-close t-tag__icon-close"
|
||||
fill="none"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M7.05 5.64L12 10.59l4.95-4.95 1.41 1.41L13.41 12l4.95 4.95-1.41 1.41L12 13.41l-4.95 4.95-1.41-1.41L10.59 12 5.64 7.05l1.41-1.41z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
|
Loading…
Reference in New Issue
Block a user