Skip to content

Commit 89c4378

Browse files
RSS1102uyarntdesign-bot
authored
refactor(select): update valueDisplay to use value prop for tag rendering (#5553)
* fix(select): update renderValueDisplay to use value prop for tag rendering * chore: optimize * chore: stash changelog [ci skip] --------- Co-authored-by: wū yāng <[email protected]> Co-authored-by: tdesign-bot <[email protected]>
1 parent c05038b commit 89c4378

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

packages/components/select/select.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,23 +475,30 @@ export default defineComponent({
475475
return undefined;
476476
}
477477
const currentSelectedOptions = getCurrentSelectedOptions(innerValue.value);
478-
return currentSelectedOptions
479-
.slice(0, props.minCollapsedNum ? props.minCollapsedNum : currentSelectedOptions.length)
480-
.map((v: TdOptionProps, key: number) => {
478+
return innerValue.value
479+
.slice(0, props.minCollapsedNum ? props.minCollapsedNum : innerValue.value.length)
480+
.map?.((v: string, key: number) => {
481+
let tagIndex: number;
482+
const option = currentSelectedOptions.find((item, index) => {
483+
if (item.value === v) {
484+
tagIndex = index;
485+
return true;
486+
}
487+
});
488+
481489
return (
482490
<Tag
483491
key={key}
484-
closable={!v?.disabled && !props.disabled && !props.readonly}
492+
closable={!option?.disabled && !props.disabled && !props.readonly}
485493
size={props.size}
486494
{...props.tagProps}
487495
onClose={({ e }: { e: MouseEvent }) => {
488496
e.stopPropagation();
489-
const index = currentSelectedOptions.findIndex((item) => item.value === v.value);
490497
props.tagProps?.onClose?.({ e });
491-
removeTag(index);
498+
removeTag(tagIndex);
492499
}}
493500
>
494-
{v?.label ?? v?.value}
501+
{option ? option.label ?? option?.value : v}
495502
</Tag>
496503
);
497504
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
pr_number: 5553
3+
contributor: RSS1102
4+
---
5+
6+
- refactor(select): 修复 `1.13.1` 版本中多选场景不存在选项中的值不能正常展示的问题 @RSS1102 ([#5553](https://github.com/Tencent/tdesign-vue-next/pull/5553))

0 commit comments

Comments
 (0)