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

feature(select): 【全部】选项文案需要支持自定义 #2208

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from
8 changes: 3 additions & 5 deletions packages/tag-input/src/tag-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@ export default defineComponent({
}
return true;
};

const isObject = typeof item === 'object';
newValue = isObject ? item[saveKey] : item.trim();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

企业微信截图_35d426cb-22be-472c-b9cf-7047b3edad3d

根据 type 已经可以确认值类型了,这个判断也可以加同时 type 看看是不是可以省略

// 自定义
if (type === 'custom') {
// 自定义时,如果配置分隔符可以一次性输入多个值
Expand All @@ -792,8 +793,6 @@ export default defineComponent({
isSelected = true;
}
} else {
const isObject = typeof item === 'object';
newValue = isObject ? item[saveKey] : item.trim();
// newValue = newValue.replace(/\s+/g, '');
if (!!newValue && !tagList.value.includes(newValue) && validateTag(newValue)) {
const localItem =
Expand All @@ -803,8 +802,7 @@ export default defineComponent({
}
}
} else if (item) {
newValue = item[saveKey];
if (newValue !== undefined && !tagList.value.includes(newValue)) {
if (!!newValue && !tagList.value.includes(newValue)) {
listState.selectedTagList.splice(targetIndex, 0, item);
isSelected = true;
}
Expand Down