From e3f02368bcd294d56446eacc0960a12996cafd63 Mon Sep 17 00:00:00 2001 From: pengYYY Date: Mon, 20 Jun 2022 19:05:31 +0800 Subject: [PATCH 1/2] fix: select options --- src/select/hooks.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/select/hooks.ts b/src/select/hooks.ts index 16dee4bfdc..23e9f0ad00 100644 --- a/src/select/hooks.ts +++ b/src/select/hooks.ts @@ -21,6 +21,7 @@ export const useSelectOptions = (props: TdSelectProps, keys: Ref index: dynamicIndex, label: get(option, label), value: get(option, value), + content: option.content, }; dynamicIndex++; return res; From 142d178796a2925125a4b7a8a20b851b8c18ad17 Mon Sep 17 00:00:00 2001 From: pengYYY Date: Mon, 20 Jun 2022 21:15:21 +0800 Subject: [PATCH 2/2] fix: select group --- src/select/helper.ts | 3 --- src/select/select-panel.tsx | 2 +- src/select/select.tsx | 6 +++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/select/helper.ts b/src/select/helper.ts index 2ef021de43..c641b13bc4 100644 --- a/src/select/helper.ts +++ b/src/select/helper.ts @@ -20,9 +20,6 @@ export const selectInjectKey: InjectionKey< export const getSingleContent = (value: TdSelectProps['value'], options: SelectOption[]): string => { for (const option of options) { - if ((option as SelectOptionGroup).children) { - return getSingleContent(value, (option as SelectOptionGroup).children); - } if ((option as TdOptionProps).value === value) { return option?.label; } diff --git a/src/select/select-panel.tsx b/src/select/select-panel.tsx index 2029ac3ec5..488e0ffc3e 100644 --- a/src/select/select-panel.tsx +++ b/src/select/select-panel.tsx @@ -45,7 +45,7 @@ export default defineComponent({ return props.filter(`${props.inputValue}`, option); } - return option.label.indexOf(`${props.inputValue}`) > -1; + return option.label?.indexOf(`${props.inputValue}`) > -1; }; return props.options.filter(filterMethods); diff --git a/src/select/select.tsx b/src/select/select.tsx index f3a1d7aa42..0279deee13 100644 --- a/src/select/select.tsx +++ b/src/select/select.tsx @@ -90,8 +90,8 @@ export default defineComponent({ // selectInput 展示值 const displayText = computed(() => props.multiple - ? getMultipleContent(innerValue.value as SelectValue[], options.value) - : getSingleContent(innerValue.value, options.value), + ? getMultipleContent(innerValue.value as SelectValue[], optionsList.value) + : getSingleContent(innerValue.value, optionsList.value), ); // valueDisplayParmas参数 @@ -254,7 +254,7 @@ export default defineComponent({ disabled={disabled.value} popupVisible={innerPopupVisible.value} inputValue={innerInputValue.value} - placeholder={placeholderText.value} + placeholder={`${placeholderText.value}`} allowInput={innerPopupVisible.value && isFilterable.value} collapsed-items={props.collapsedItems} inputProps={{