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): 修复多选模式下key可能为undefined的场景 #8042

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Carryours
Copy link

@Carryours Carryours commented Feb 14, 2025

场景

Select组件为多选模式下,options从远程加载时。如果初始值中包含未加载到的option选项,会导致key值为undefined。
OverFlow组件在渲染标签Item时,如果没有key值会使用index作为key,并且当option的value值为number类型,则会导致key值重复并且删除Selected值会出现问题。

关联代码

 // ================================= Item =================================
  const getKey = (item: any, index: number) => {
    if (typeof props.itemKey === 'function') {
      return props.itemKey(item);
    }
    return (props.itemKey && (item as any)?.[props.itemKey]) ?? index;
  };

复现场景

录屏2025-02-14 14 43 25

https://codesandbox.io/p/sandbox/elastic-river-ng9wcp?file=%2Fsrc%2FApp.vue%3A10%2C31

修复后

2025-02-14.14.54.56.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant