File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -225,8 +225,9 @@ function calculateNewValue(
225225 inputType === 'changeNumberInput'
226226 ) {
227227 const reachedMax = value === node . max
228+ const step = node . step ? Number ( node . step ) : 1
228229 if ( inputData === 'ArrowUp' && ! reachedMax ) {
229- newValue = ( Number ( value ) + 1 ) . toString ( )
230+ newValue = ( Number ( value ) + step ) . toString ( )
230231 }
231232
232233 const reachedMin = value === node . min
Original file line number Diff line number Diff line change @@ -431,3 +431,15 @@ test("do not decrement number input's value when pressing the arrow down key and
431431
432432 expect ( element ) . toHaveValue ( 1 )
433433} )
434+
435+ test ( "increments number input's value by the defined steps when pressing the arrow up key" , ( ) => {
436+ const { element} = render < HTMLInputElement > (
437+ `<input value="10" type="number" step="10"/>` ,
438+ )
439+
440+ const instance = setupInstance ( )
441+
442+ instance . dispatchUIEvent ( element , 'keydown' , { key : 'ArrowUp' } )
443+
444+ expect ( element ) . toHaveValue ( 20 )
445+ } )
You can’t perform that action at this time.
0 commit comments