input icon indicating copy to clipboard operation
input copied to clipboard

onPressEnter failed to trigger after the input blurs. 输入框失焦后onPressEnter不会被触发

Open zhangbenber opened this issue 6 months ago • 0 comments

This issue was introduced by: https://github.com/react-component/input/commit/e9d6848c41521548992608559019b1d6820f6022.

When the input lost focus after the user presses Enter and before releasing it (which is a common usage for disable or hide the input via CSS when hit Enter), the onPressEnter will never trigger again, since onKeyUp should never trigger on that element and keyLockRef.current are always true after then.

Maybe we should reset the keyLockRef to false in the handleBlur handler.

这是个由 https://github.com/react-component/input/commit/e9d6848c41521548992608559019b1d6820f6022 引入的问题。

当用户按下 Enter 之后,松开按键之前,如果输入框丢失了焦点(这种情况很容易出现在:需要在按回车的时候禁用或者用 CSS 隐藏输入框的场景),则之后 onPressEnter 不会再触发。因为此时元素的 onKeyUp 不会发生,之后 keyLockRef.current 就一直是 true 了。

或许需要在 handleBlur 中把 keyLockRef 重置为 false

zhangbenber avatar Aug 28 '24 06:08 zhangbenber