@@ -8,29 +8,49 @@ export default React.forwardRef<HTMLInputElement, SharedContentProps>(function S
88 { inputProps } ,
99 ref ,
1010) {
11- const { prefixCls, searchValue, displayValues, maxLength, mode } = useSelectInputContext ( ) ;
11+ const { prefixCls, searchValue, activeValue, displayValues, maxLength, mode, onSearch } =
12+ useSelectInputContext ( ) ;
1213
14+ const [ inputChanged , setInputChanged ] = React . useState ( false ) ;
15+
16+ const combobox = mode === 'combobox' ;
1317 const displayValue = displayValues [ 0 ] ;
1418
19+ // Implement the same logic as the old SingleSelector
20+ let mergedSearchValue : string = searchValue || '' ;
21+ if ( combobox && activeValue && ! inputChanged ) {
22+ mergedSearchValue = activeValue ;
23+ }
24+
25+ React . useEffect ( ( ) => {
26+ if ( combobox ) {
27+ setInputChanged ( false ) ;
28+ }
29+ } , [ combobox , activeValue ] ) ;
30+
1531 return (
1632 < div className = { `${ prefixCls } -content` } >
1733 { displayValue ? (
1834 < div
1935 className = { `${ prefixCls } -content-value` }
2036 style = { {
21- visibility : searchValue ? 'hidden' : 'visible' ,
37+ visibility : mergedSearchValue ? 'hidden' : 'visible' ,
2238 } }
2339 >
2440 { displayValue . label }
2541 </ div >
2642 ) : (
27- < Placeholder />
43+ < Placeholder hasSearchValue = { ! ! mergedSearchValue } />
2844 ) }
2945 < Input
3046 ref = { ref }
3147 { ...inputProps }
32- value = { searchValue }
48+ value = { mergedSearchValue }
3349 maxLength = { mode === 'combobox' ? maxLength : undefined }
50+ onChange = { ( e ) => {
51+ setInputChanged ( true ) ;
52+ inputProps . onChange ?.( e ) ;
53+ } }
3454 />
3555 </ div >
3656 ) ;
0 commit comments