From a0886fbb49a79e219a068b89fc1d7b59876402fa Mon Sep 17 00:00:00 2001 From: melloware Date: Tue, 19 Mar 2024 08:11:27 -0400 Subject: [PATCH] Fix #6173: TreeSelect emptyMessage allow JSX content --- components/lib/treeselect/TreeSelect.js | 3 ++- components/lib/treeselect/treeselect.d.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/lib/treeselect/TreeSelect.js b/components/lib/treeselect/TreeSelect.js index c04667d49b..8f0e3b0e6d 100644 --- a/components/lib/treeselect/TreeSelect.js +++ b/components/lib/treeselect/TreeSelect.js @@ -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') @@ -671,7 +672,7 @@ export const TreeSelect = React.memo( __parentMetadata={{ parent: metaData }} > - {hasNoOptions &&
{props.emptyMessage || localeOption('emptyMessage')}
} + {hasNoOptions &&
{message}
} ); }; diff --git a/components/lib/treeselect/treeselect.d.ts b/components/lib/treeselect/treeselect.d.ts index 4549877164..9d0c4384a7 100644 --- a/components/lib/treeselect/treeselect.d.ts +++ b/components/lib/treeselect/treeselect.d.ts @@ -411,8 +411,9 @@ export interface TreeSelectProps extends Omit | 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. */