diff --git a/src/SelectInput/Content/SingleContent.tsx b/src/SelectInput/Content/SingleContent.tsx index d5237f8c..3a731a38 100644 --- a/src/SelectInput/Content/SingleContent.tsx +++ b/src/SelectInput/Content/SingleContent.tsx @@ -19,7 +19,6 @@ const SingleContent = React.forwardRef( const combobox = mode === 'combobox'; const displayValue = displayValues[0]; - const hasDisplayValue = displayValue !== null && displayValue !== undefined; // Implement the same logic as the old SingleSelector const mergedSearchValue = React.useMemo(() => { @@ -35,7 +34,7 @@ const SingleContent = React.forwardRef( let style: React.CSSProperties | undefined; let titleValue: string | undefined; - if (hasDisplayValue && selectContext?.flattenOptions) { + if (displayValue && selectContext?.flattenOptions) { const option = selectContext.flattenOptions.find((opt) => opt.value === displayValue.value); if (option?.data) { className = option.data.className; @@ -44,7 +43,7 @@ const SingleContent = React.forwardRef( } } - if (hasDisplayValue && !titleValue) { + if (displayValue && !titleValue) { titleValue = getTitle(displayValue); } @@ -65,7 +64,7 @@ const SingleContent = React.forwardRef( // ========================== Render ========================== // Render value - const renderValue = hasDisplayValue ? ( + const renderValue = displayValue ? ( hasOptionStyle ? (
(
{ }); expect(container.querySelector('.rc-select-placeholder').textContent).toBe('placeholder'); }); - - it('should have content-has-value class when value is empty string', () => { - const { container } = render( -