@@ -122,7 +122,6 @@ const Input = forwardRefWithStatics(
122122 // inputPreRef 用于预存输入框宽度,应用在 auto width 模式中
123123 const inputPreRef : React . RefObject < HTMLInputElement > = useRef ( null ) ;
124124 const wrapperRef : React . RefObject < HTMLDivElement > = useRef ( null ) ;
125- const isClickingIconRef = useRef ( false ) ;
126125
127126 const [ isHover , toggleIsHover ] = useState ( false ) ;
128127 const [ isFocused , toggleIsFocused ] = useState ( false ) ;
@@ -143,7 +142,6 @@ const Input = forwardRefWithStatics(
143142 suffixIconNew = (
144143 < CloseCircleFilledIcon
145144 className = { `${ classPrefix } -input__suffix-clear` }
146- onMouseDown = { handleMouseDown }
147145 onClick = { handleClear }
148146 />
149147 ) ;
@@ -157,7 +155,6 @@ const Input = forwardRefWithStatics(
157155 suffixIconNew = (
158156 < PasswordIcon
159157 className = { `${ classPrefix } -input__suffix-clear` }
160- onMouseDown = { handleMouseDown }
161158 onClick = { togglePasswordVisible }
162159 />
163160 ) ;
@@ -273,6 +270,7 @@ const Input = forwardRefWithStatics(
273270 } ) }
274271 onMouseEnter = { handleMouseEnter }
275272 onMouseLeave = { handleMouseLeave }
273+ onMouseDown = { handleMouseDown }
276274 onWheel = { ( e ) => onWheel ?.( { e } ) }
277275 onClick = { ( e ) => {
278276 inputRef . current ?. focus ( ) ;
@@ -308,7 +306,6 @@ const Input = forwardRefWithStatics(
308306
309307 requestAnimationFrame ( ( ) => {
310308 inputEl ?. setSelectionRange ( cursorPosition , cursorPosition ) ;
311- isClickingIconRef . current = false ;
312309 } ) ;
313310 }
314311
@@ -330,18 +327,15 @@ const Input = forwardRefWithStatics(
330327 }
331328 // 添加MouseDown阻止冒泡,防止點擊Clear value會導致彈窗閃爍一下
332329 // https://github.com/Tencent/tdesign-react/issues/2320
333- function handleMouseDown ( e : React . MouseEvent < SVGSVGElement , globalThis . MouseEvent > ) {
330+ function handleMouseDown ( e : React . MouseEvent < HTMLDivElement , globalThis . MouseEvent > ) {
331+ e . preventDefault ( ) ; // 阻止默认行为,防止焦点转移
334332 e . stopPropagation ( ) ;
335333 // 兼容React16
336334 e . nativeEvent . stopImmediatePropagation ( ) ;
337- isClickingIconRef . current = true ;
338335 }
339336 function handleClear ( e : React . MouseEvent < SVGSVGElement > ) {
340337 onChange ?.( '' , { e, trigger : 'clear' } ) ;
341338 onClear ?.( { e } ) ;
342- requestAnimationFrame ( ( ) => {
343- isClickingIconRef . current = false ;
344- } ) ;
345339 }
346340 function handleKeyDown ( e : React . KeyboardEvent < HTMLInputElement > ) {
347341 const {
@@ -382,7 +376,6 @@ const Input = forwardRefWithStatics(
382376 }
383377
384378 function handleFocus ( e : React . FocusEvent < HTMLInputElement > ) {
385- if ( isClickingIconRef . current ) return ;
386379 const {
387380 currentTarget : { value } ,
388381 } = e ;
@@ -392,7 +385,6 @@ const Input = forwardRefWithStatics(
392385 }
393386
394387 function handleBlur ( e : React . FocusEvent < HTMLInputElement > ) {
395- if ( isClickingIconRef . current ) return ;
396388 const {
397389 currentTarget : { value } ,
398390 } = e ;
0 commit comments