File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,8 @@ const InputNumber = React.forwardRef(
141
141
142
142
const userTypingRef = React . useRef ( false ) ;
143
143
const compositionRef = React . useRef ( false ) ;
144
+ const keydownRef = React . useRef ( false ) ;
145
+ const onChangeRef = React . useRef < ( ) => void > ( ) ;
144
146
145
147
// ============================ Value =============================
146
148
// Real value control
@@ -401,6 +403,13 @@ const InputNumber = React.forwardRef(
401
403
402
404
// >>> Input
403
405
const onInternalInput : React . ChangeEventHandler < HTMLInputElement > = ( e ) => {
406
+ if ( ! keydownRef . current ) {
407
+ const v = e . target . value ;
408
+ onChangeRef . current = ( ) => {
409
+ collectInputValue ( v ) ;
410
+ } ;
411
+ return ;
412
+ }
404
413
collectInputValue ( e . target . value ) ;
405
414
} ;
406
415
@@ -469,6 +478,12 @@ const InputNumber = React.forwardRef(
469
478
onPressEnter ?.( event ) ;
470
479
}
471
480
481
+ keydownRef . current = true ;
482
+ if ( onChangeRef . current ) {
483
+ onChangeRef . current ( ) ;
484
+ onChangeRef . current = undefined ;
485
+ }
486
+
472
487
if ( keyboard === false ) {
473
488
return ;
474
489
}
@@ -482,6 +497,7 @@ const InputNumber = React.forwardRef(
482
497
483
498
const onKeyUp = ( ) => {
484
499
userTypingRef . current = false ;
500
+ keydownRef . current = false ;
485
501
} ;
486
502
487
503
// >>> Focus & Blur
You can’t perform that action at this time.
0 commit comments