From f4c65cde6ad00364344b7ead6d24e348795de1fc 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: Tue, 24 Feb 2026 19:46:03 +0800 Subject: [PATCH] fix: do not render value in combobox mode with custom input Co-Authored-By: Claude Opus 4.6 --- src/SelectInput/Content/SingleContent.tsx | 39 ++++++++++++----------- tests/Combobox.test.tsx | 25 +++++++++++++++ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/SelectInput/Content/SingleContent.tsx b/src/SelectInput/Content/SingleContent.tsx index 6a44357f..a9c1acd3 100644 --- a/src/SelectInput/Content/SingleContent.tsx +++ b/src/SelectInput/Content/SingleContent.tsx @@ -10,7 +10,7 @@ import { getTitle } from '../../utils/commonUtil'; const SingleContent = React.forwardRef( ({ inputProps }, ref) => { - const { prefixCls, searchValue, activeValue, displayValues, maxLength, mode } = + const { prefixCls, searchValue, activeValue, displayValues, maxLength, mode, components } = useSelectInputContext(); const { triggerOpen, title: rootTitle, showSearch, classNames, styles } = useBaseProps(); const selectContext = React.useContext(SelectContext); @@ -70,25 +70,28 @@ const SingleContent = React.forwardRef( String(displayValue.label).trim() !== ''; // Render value - const renderValue = displayValue ? ( - hasOptionStyle ? ( -
- {displayValue.label} -
+ // Only render value when not using custom input in combobox mode + const shouldRenderValue = !(combobox && components?.input); + const renderValue = shouldRenderValue ? ( + displayValue ? ( + hasOptionStyle ? ( +
+ {displayValue.label} +
+ ) : ( + displayValue.label + ) ) : ( - displayValue.label + ) - ) : ( - - ); - + ) : null; // Render return (
{ fireEvent(selectorEle, mouseDownEvent); expect(preventDefault).not.toHaveBeenCalled(); }); + + // https://github.com/ant-design/ant-design/issues/56948 + // https://github.com/ant-design/ant-design/issues/56932 + it('should not render value in combobox mode with custom input', () => { + const CustomInput = (props: any) => ; + + const { container } = render( + , + ); + + // with custom input in combobox mode, renderValue should be null + // So we should only see the input element, not the rendered value div + expect(container.querySelector('.rc-select-content-value')).toBeFalsy(); + expect(container.querySelector('.rc-select-placeholder')).toBeFalsy(); + expect(container.querySelector('input')).toHaveValue('1'); + expect(container.querySelector('input')).toHaveAttribute('placeholder', 'Input value'); + }); }); });