@@ -68,6 +68,14 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
68
68
const valueLength = countConfig . strategy ( formatValue ) ;
69
69
70
70
const isOutOfRange = ! ! mergedMax && valueLength > mergedMax ;
71
+ const isExceed = ( currentValue : string ) => {
72
+ return (
73
+ ! compositionRef . current &&
74
+ countConfig . exceedFormatter &&
75
+ countConfig . max &&
76
+ countConfig . strategy ( currentValue ) > countConfig . max
77
+ ) ;
78
+ } ;
71
79
72
80
// ======================= Ref ========================
73
81
useImperativeHandle ( ref , ( ) => ( {
@@ -100,14 +108,9 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
100
108
) => {
101
109
let cutValue = currentValue ;
102
110
103
- if (
104
- ! compositionRef . current &&
105
- countConfig . exceedFormatter &&
106
- countConfig . max &&
107
- countConfig . strategy ( currentValue ) > countConfig . max
108
- ) {
109
- cutValue = countConfig . exceedFormatter ( currentValue , {
110
- max : countConfig . max ,
111
+ if ( isExceed ( currentValue ) ) {
112
+ cutValue = countConfig . exceedFormatter ! ( currentValue , {
113
+ max : countConfig . max ! ,
111
114
} ) ;
112
115
113
116
if ( currentValue !== cutValue ) {
@@ -138,7 +141,8 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
138
141
e : React . CompositionEvent < HTMLInputElement > ,
139
142
) => {
140
143
compositionRef . current = false ;
141
- triggerChange ( e , e . currentTarget . value ) ;
144
+ if ( isExceed ( e . currentTarget . value ) )
145
+ triggerChange ( e , e . currentTarget . value ) ;
142
146
onCompositionEnd ?.( e ) ;
143
147
} ;
144
148
0 commit comments