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 #6173: TreeSelect emptyMessage allow JSX content #6177

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/lib/treeselect/TreeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ export const TreeSelect = React.memo(
};

const createContent = () => {
const message = ObjectUtils.getJSXElement(props.emptyMessage, props) || localeOption('emptyMessage');
const emptyMessageProps = mergeProps(
{
className: cx('emptyMessage')
Expand Down Expand Up @@ -671,7 +672,7 @@ export const TreeSelect = React.memo(
__parentMetadata={{ parent: metaData }}
></Tree>

{hasNoOptions && <div {...emptyMessageProps}>{props.emptyMessage || localeOption('emptyMessage')}</div>}
{hasNoOptions && <div {...emptyMessageProps}>{message}</div>}
</>
);
};
Expand Down
3 changes: 2 additions & 1 deletion components/lib/treeselect/treeselect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,9 @@ export interface TreeSelectProps extends Omit<React.DetailedHTMLProps<React.Inpu
dropdownIcon?: IconType<TreeSelectProps> | undefined;
/**
* Text to display when there is no data.
* @defaultValue No available options
*/
emptyMessage?: string | undefined;
emptyMessage?: React.ReactNode | ((props: TreeSelectProps) => React.ReactNode) | undefined;
/**
* An array of keys to represent the state of the treeselect expansion state in controlled mode.
*/
Expand Down
Loading