From f9e86e28aa28e18c6b62b8346848fb207ef3ffbf Mon Sep 17 00:00:00 2001 From: bestlyg Date: Fri, 15 Mar 2024 14:27:34 +0800 Subject: [PATCH 1/2] fix: can not use suffix and addAfter prop in input-search --- components/Input/search.tsx | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/components/Input/search.tsx b/components/Input/search.tsx index f03914d917..1f16635935 100644 --- a/components/Input/search.tsx +++ b/components/Input/search.tsx @@ -13,8 +13,18 @@ import { isObject } from '../_util/is'; const Search = React.forwardRef((props: InputSearchProps, ref) => { const { getPrefixCls } = useContext(ConfigContext); - const { className, style, placeholder, disabled, searchButton, loading, defaultValue, ...rest } = - props; + const { + className, + style, + placeholder, + disabled, + searchButton, + loading, + defaultValue, + addAfter, + suffix, + ...rest + } = props; const trueMaxLength = isObject(props.maxLength) ? props.maxLength.length : props.maxLength; const mergedMaxLength = @@ -48,7 +58,9 @@ const Search = React.forwardRef((props: InputSea ref={ref} placeholder={placeholder} addAfter={ - searchButton ? ( + addAfter !== undefined ? ( + addAfter + ) : searchButton ? ( ) : null } - suffix={!searchButton && (loading ? : )} + suffix={ + suffix !== undefined + ? suffix + : !searchButton && (loading ? : ) + } onChange={(value, e) => { setValue(value); props.onChange && props.onChange(value, e); From b9176364a62716680abfbb4dbcf1878ece78c25e Mon Sep 17 00:00:00 2001 From: bestlyg Date: Mon, 18 Mar 2024 11:53:17 +0800 Subject: [PATCH 2/2] fix: auto-complete compatible input-search --- components/AutoComplete/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/AutoComplete/index.tsx b/components/AutoComplete/index.tsx index 06ee7a082d..5e148f03ff 100644 --- a/components/AutoComplete/index.tsx +++ b/components/AutoComplete/index.tsx @@ -130,7 +130,12 @@ function AutoComplete(baseProps: AutoCompleteProps, ref) { ...inputProps, ...pickDataAttributes(props), // Empty tag to ensure the consistency of the dom structure of input, such that input won't accidentally lose focus due to structure change on input. - suffix: loading ? : inputProps?.suffix || , + suffix: loading ? ( + + ) : (usedTriggerElement?.type as unknown as { displayName: string })?.displayName === + 'Search' ? undefined : ( + inputProps?.suffix || + ), onFocus: (event) => { setIsFocused(true); onFocus?.(event);