@@ -35,23 +35,13 @@ export default React.forwardRef<HTMLInputElement, SharedContentProps>(function M
3535 maxTagTextLength,
3636 maxTagCount,
3737 tagRender : tagRenderFromContext ,
38+ focused,
3839 } = useSelectInputContext ( ) ;
39- const { disabled, showSearch, open, toggleOpen } = useBaseProps ( ) ;
40-
41- const measureRef = React . useRef < HTMLSpanElement > ( null ) ;
42- const [ inputWidth , setInputWidth ] = useState ( 0 ) ;
43- const [ focused , setFocused ] = useState ( false ) ;
40+ const { disabled, showSearch, triggerOpen, toggleOpen } = useBaseProps ( ) ;
4441
4542 // ===================== Search ======================
4643 const inputValue = showSearch ? searchValue : '' ;
47- const inputEditable : boolean = showSearch && ( open || focused ) ;
48-
49- // We measure width and set to the input immediately
50- useLayoutEffect ( ( ) => {
51- if ( measureRef . current ) {
52- setInputWidth ( measureRef . current . scrollWidth ) ;
53- }
54- } , [ inputValue ] ) ;
44+ const inputEditable : boolean = showSearch && ( triggerOpen || focused ) ;
5545
5646 // Props from context with safe defaults
5747 const removeIcon : RenderNode = removeIconFromContext ?? '×' ;
@@ -111,7 +101,7 @@ export default React.forwardRef<HTMLInputElement, SharedContentProps>(function M
111101 ) => {
112102 const onMouseDown = ( e : React . MouseEvent ) => {
113103 onPreventMouseDown ( e ) ;
114- onToggleOpen ( ! open ) ;
104+ onToggleOpen ( ! triggerOpen ) ;
115105 } ;
116106 return (
117107 < span onMouseDown = { onMouseDown } >
@@ -128,34 +118,6 @@ export default React.forwardRef<HTMLInputElement, SharedContentProps>(function M
128118 ) ;
129119 } ;
130120
131- // ======================= Input ========================
132- // >>> Input Node
133- const inputNode = (
134- < div
135- className = { `${ prefixCls } -search` }
136- style = { { width : inputWidth } }
137- onFocus = { ( ) => {
138- setFocused ( true ) ;
139- } }
140- onBlur = { ( ) => {
141- setFocused ( false ) ;
142- } }
143- >
144- < Input
145- ref = { ref }
146- disabled = { disabled }
147- readOnly = { ! inputEditable }
148- { ...inputProps }
149- value = { inputValue || '' }
150- />
151-
152- { /* Measure Node */ }
153- < span ref = { measureRef } className = { `${ prefixCls } -search-mirror` } aria-hidden >
154- { inputValue }
155- </ span >
156- </ div >
157- ) ;
158-
159121 // ====================== Overflow ======================
160122 const renderItem = ( valueItem : DisplayValueType , info : { index : number } ) => {
161123 const { disabled : itemDisabled , label, value } = valueItem ;
@@ -207,13 +169,6 @@ export default React.forwardRef<HTMLInputElement, SharedContentProps>(function M
207169 } ;
208170
209171 // ======================= Render =======================
210- // return (
211- // // <div className={`${prefixCls}-content`}>
212- // {/* <Input ref={ref} {...inputProps} value={searchValue} /> */ }
213-
214- // // </div>
215- // );
216-
217172 return (
218173 < Overflow
219174 prefixCls = { `${ prefixCls } -content` }
0 commit comments