@@ -43,10 +43,13 @@ function UnforwardedNumberControl(
43
43
const isStepAny = step === 'any' ;
44
44
const baseStep = isStepAny ? 1 : ensureNumber ( step ) ;
45
45
const baseValue = roundClamp ( 0 , min , max , baseStep ) ;
46
- const constrainValue = ( value : number , stepOverride ?: number ) => {
46
+ const constrainValue = (
47
+ value : number | string ,
48
+ stepOverride ?: number
49
+ ) => {
47
50
// When step is "any" clamp the value, otherwise round and clamp it.
48
51
return isStepAny
49
- ? Math . min ( max , Math . max ( min , value ) )
52
+ ? Math . min ( max , Math . max ( min , ensureNumber ( value ) ) )
50
53
: roundClamp ( value , min , max , stepOverride ?? baseStep ) ;
51
54
} ;
52
55
@@ -91,18 +94,15 @@ function UnforwardedNumberControl(
91
94
}
92
95
93
96
if ( type === inputControlActionTypes . PRESS_UP ) {
94
- // @ts -expect-error TODO: isValueEmpty() needs to be typed properly
95
97
nextValue = add ( nextValue , incrementalValue ) ;
96
98
}
97
99
98
100
if ( type === inputControlActionTypes . PRESS_DOWN ) {
99
- // @ts -expect-error TODO: isValueEmpty() needs to be typed properly
100
101
nextValue = subtract ( nextValue , incrementalValue ) ;
101
102
}
102
103
103
104
// @ts -expect-error TODO: Resolve discrepancy between `value` types in InputControl based components
104
105
nextState . value = constrainValue (
105
- // @ts -expect-error TODO: isValueEmpty() needs to be typed properly
106
106
nextValue ,
107
107
enableShift ? incrementalValue : undefined
108
108
) ;
@@ -151,7 +151,7 @@ function UnforwardedNumberControl(
151
151
152
152
// @ts -expect-error TODO: Resolve discrepancy between `value` types in InputControl based components
153
153
nextState . value = constrainValue (
154
- // @ts -expect-error TODO: isValueEmpty() needs to be typed properly
154
+ // @ts -expect-error TODO: Investigate if it's ok for currentValue to be undefined
155
155
add ( currentValue , distance ) ,
156
156
enableShift ? modifier : undefined
157
157
) ;
@@ -171,7 +171,7 @@ function UnforwardedNumberControl(
171
171
// @ts -expect-error TODO: Resolve discrepancy between `value` types in InputControl based components
172
172
nextState . value = applyEmptyValue
173
173
? currentValue
174
- : // @ts -expect-error TODO: isValueEmpty() needs to be typed properly
174
+ : // @ts -expect-error TODO: Investigate if it's ok for currentValue to be undefined
175
175
constrainValue ( currentValue ) ;
176
176
}
177
177
0 commit comments