Skip to content

Commit

Permalink
fix(layout): fix ProFormSelect unsupport title error
Browse files Browse the repository at this point in the history
close #7506
  • Loading branch information
chenshuai2144 committed Aug 13, 2023
1 parent c721e07 commit d41b1a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
12 changes: 7 additions & 5 deletions packages/field/src/components/Select/SearchSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const SearchSelect = <T,>(props: SearchSelectProps<T[]>, 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,
Expand All @@ -182,17 +182,19 @@ const SearchSelect = <T,>(props: SearchSelectProps<T[]>, ref: any) => {

if (optionType === 'optGroup' || item.options) {
return {
...resetItem,
label: label,
...resetItem,
data_title: label,
title: label,
key: value ?? label?.toString(),
children: genOptions(itemOptions),
} as DefaultOptionType;
}

return {
...resetItem,
title: label,
...resetItem,
data_title: label,
value: value ?? index,
key: value ?? label?.toString(),
'data-item': item,
Expand Down Expand Up @@ -231,11 +233,11 @@ const SearchSelect = <T,>(props: SearchSelectProps<T[]>, 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()) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export const ActionsContent: React.FC<GlobalHeaderProps> = ({
if (!avatarProps) return null;
const { title, render, ...rest } = avatarProps;
const domList = [
<Avatar {...rest} size={28} key="avatar" />,
rest?.src || rest?.srcSet || rest.icon || rest.children ? (
<Avatar {...rest} size={28} key="avatar" />
) : null,
title ? (
<span
key="name"
Expand Down
4 changes: 3 additions & 1 deletion packages/layout/src/components/SiderMenu/SiderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ const SiderMenu: React.FC<SiderMenuProps & PrivateSiderMenuProps> = (props) => {
const { title, render, ...rest } = avatarProps;
const dom = (
<div className={`${baseClassName}-actions-avatar`}>
{rest?.src || rest?.srcSet ? <Avatar size={28} {...rest} /> : null}
{rest?.src || rest?.srcSet || rest.icon || rest.children ? (
<Avatar size={28} {...rest} />
) : null}
{avatarProps.title && !collapsed && <span>{title}</span>}
</div>
);
Expand Down

0 comments on commit d41b1a7

Please sign in to comment.