Skip to content

Commit 7b0ae73

Browse files
committed
fix(VOtpInput): move to proper input when input index is not next
1 parent a3dfe1b commit 7b0ae73

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/vuetify/src/labs/VOtpInput/VOtpInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const VOtpInput = genericComponent<VOtpInputSlots>()({
107107
let target: any = null
108108

109109
if (focusIndex.value > model.value.length) {
110-
target = model.value.length + 1
110+
target = model.value.length
111111
} else if (focusIndex.value + 1 !== Number(props.length)) {
112112
target = 'next'
113113
} else {

packages/vuetify/src/labs/VOtpInput/__tests__/VOtpInput.spec.cy.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ describe('VOtpInput', () => {
2929
.should('not.be.focused')
3030
})
3131

32+
it('enters value and moves to next input when focused index is not next', () => {
33+
cy.mount(() => (<VOtpInput />))
34+
.get('.v-otp-input input').eq(0)
35+
.type('1')
36+
.get('.v-otp-input input').eq(1)
37+
.should('be.focused')
38+
.get('.v-otp-input input').eq(3)
39+
.type('2')
40+
.get('.v-otp-input input').eq(2)
41+
.should('be.focused')
42+
})
43+
3244
it('removes value and stays on current input when using delete', () => {
3345
cy.mount(() => (<VOtpInput />))
3446
.get('.v-otp-input input').eq(0)

0 commit comments

Comments
 (0)