Skip to content

Commit ef4116c

Browse files
committed
fix(VOtpInput): trim clipboard text and update focus on finish
1 parent 53ef868 commit ef4116c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/vuetify/src/components/VOtpInput/VOtpInput.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const VOtpInput = genericComponent<VOtpInputSlots>()({
166166
e.preventDefault()
167167
e.stopPropagation()
168168

169-
const clipboardText = e?.clipboardData?.getData('Text').slice(0, length.value) ?? ''
169+
const clipboardText = e?.clipboardData?.getData('Text').trim().slice(0, length.value) ?? ''
170170

171171
if (isValidNumber(clipboardText)) return
172172

@@ -207,7 +207,10 @@ export const VOtpInput = genericComponent<VOtpInputSlots>()({
207207
}, { scoped: true })
208208

209209
watch(model, val => {
210-
if (val.length === length.value) emit('finish', val.join(''))
210+
if (val.length === length.value) {
211+
focusIndex.value = length.value - 1
212+
emit('finish', val.join(''))
213+
}
211214
}, { deep: true })
212215

213216
watch(focusIndex, val => {

0 commit comments

Comments
 (0)