Skip to content

Commit

Permalink
Fix #6173: TreeSelect emptyMessage allow JSX content
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Mar 19, 2024
1 parent dd799ec commit a0886fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit a0886fb

Please sign in to comment.