From ed52b4e8443ba2805d68b0d968b73c68005464ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Fri, 13 Feb 2026 14:59:44 +0800 Subject: [PATCH 1/2] fix: handle whitespace-only values in content-has-value class --- src/SelectInput/Content/SingleContent.tsx | 13 ++++++++----- tests/Select.test.tsx | 11 ++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/SelectInput/Content/SingleContent.tsx b/src/SelectInput/Content/SingleContent.tsx index 55008591..3a24744b 100644 --- a/src/SelectInput/Content/SingleContent.tsx +++ b/src/SelectInput/Content/SingleContent.tsx @@ -63,6 +63,13 @@ const SingleContent = React.forwardRef( }, [combobox, activeValue]); // ========================== Render ========================== + const showHasValueCls = !!( + displayValue && + displayValue.label !== null && + displayValue.label !== undefined && + String(displayValue.label).trim() !== '' + ); + // Render value const renderValue = displayValue ? ( hasOptionStyle ? ( @@ -88,11 +95,7 @@ const SingleContent = React.forwardRef(
{ const { container } = render( , ); expect(container.querySelector('.rc-select-content-has-value')).toBeTruthy(); }); + it('should not add -content-has-value className when value is whitespace string', () => { + const { container } = render( + , + ); + expect(container.querySelector('.rc-select-content-has-value')).toBeFalsy(); + }); + it('should default select the right option', () => { const { container } = render(