From d41b1a74233bc6900c0360866c2738bcf62cbcff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9F=E8=B4=A4?= Date: Sun, 13 Aug 2023 20:32:30 +0800 Subject: [PATCH] fix(layout): fix ProFormSelect unsupport title error close https://github.com/ant-design/pro-components/issues/7506 --- .../src/components/Select/SearchSelect/index.tsx | 12 +++++++----- .../src/components/GlobalHeader/ActionsContent.tsx | 4 +++- .../layout/src/components/SiderMenu/SiderMenu.tsx | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/field/src/components/Select/SearchSelect/index.tsx b/packages/field/src/components/Select/SearchSelect/index.tsx index 587d21942ca0..744f596a622a 100644 --- a/packages/field/src/components/Select/SearchSelect/index.tsx +++ b/packages/field/src/components/Select/SearchSelect/index.tsx @@ -155,7 +155,7 @@ const SearchSelect = (props: SearchSelectProps, ref: any) => { if (Array.isArray(value) && value.length > 0) { // 多选情况且用户有选择 return value.map((item, index) => { - const optionItem = option?.[index]; + const optionItem = option?.[index] as DefaultOptionType; const dataItem = optionItem?.['data-item'] || {}; return { ...dataItem, @@ -182,8 +182,9 @@ const SearchSelect = (props: SearchSelectProps, ref: any) => { if (optionType === 'optGroup' || item.options) { return { - ...resetItem, label: label, + ...resetItem, + data_title: label, title: label, key: value ?? label?.toString(), children: genOptions(itemOptions), @@ -191,8 +192,9 @@ const SearchSelect = (props: SearchSelectProps, ref: any) => { } return { - ...resetItem, title: label, + ...resetItem, + data_title: label, value: value ?? index, key: value ?? label?.toString(), 'data-item': item, @@ -231,11 +233,11 @@ const SearchSelect = (props: SearchSelectProps, ref: any) => { ) { return restProps.filterOption(inputValue, { ...option, - label: option?.title, + label: option?.data_title, }); } return !!( - option?.title + option?.data_title ?.toString() .toLowerCase() .includes(inputValue.toLowerCase()) || diff --git a/packages/layout/src/components/GlobalHeader/ActionsContent.tsx b/packages/layout/src/components/GlobalHeader/ActionsContent.tsx index 931319a4bb93..373c5131ae7a 100644 --- a/packages/layout/src/components/GlobalHeader/ActionsContent.tsx +++ b/packages/layout/src/components/GlobalHeader/ActionsContent.tsx @@ -28,7 +28,9 @@ export const ActionsContent: React.FC = ({ if (!avatarProps) return null; const { title, render, ...rest } = avatarProps; const domList = [ - , + rest?.src || rest?.srcSet || rest.icon || rest.children ? ( + + ) : null, title ? ( = (props) => { const { title, render, ...rest } = avatarProps; const dom = (
- {rest?.src || rest?.srcSet ? : null} + {rest?.src || rest?.srcSet || rest.icon || rest.children ? ( + + ) : null} {avatarProps.title && !collapsed && {title}}
);