Skip to content

fix: added delete key handling to InputOtp - #716

Open
tokainz wants to merge 1 commit into
openvi-foundation:masterfrom
tokainz:fix/529-inputotp-delete-key
Open

tokainz wants to merge 1 commit into
openvi-foundation:masterfrom
tokainz:fix/529-inputotp-delete-key

Conversation

@tokainz

@tokainz tokainz commented Nov 16, 2026

Copy link
Copy Markdown

What does this PR do?

Pressing Delete in the middle of an InputOtp field removed the character, but then moved the focus to the next field with the caret at the end, so further presses of Delete did nothing.

The input event with inputType: 'deleteContentForward' was handled like typing and called moveToNext(). Because the model is joined without gaps, the following values shift one field to the left on re-render, which also cleared the selection in the newly focused field.
deleteContentForward now keeps the focus on the current field and selects its new value after the re-render. Pressing Delete repeatedly removes the following characters one by one, like in a regular text field.

Example old:
Fill InputOtp with the values 1, 2, 3, 4 and focus the field with value 1. Press Delete and the value 1 will be deleted but the focus will jump to the second field and the caret is placed at the end of the input so pressing Delete again does nothing.

Example new:
Fill InputOtp same as above. Focus Value 1. Press Delete and value 1 will be deleted and value 2 will be in its place. The focus should stay on the first Input. Press Delete again and value 2 will also be deleted, and so on.

Also:

  • Added a delete entry to the accessibility doc of InputOtp.
  • Added InputOtp.spec.js because there were no tests for the InputOtp yet. Besides the Delete key, it covers props, typing, max length, arrow keys, Backspace and paste.

Related issue

Closes #529

Checklist

  • Tests added or updated for the change
  • pnpm run lint and pnpm run format pass
  • Changelog entry added under ## [Unreleased] in CHANGELOG.md

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

@tokainz is attempting to deploy a commit to the njevric's projects Team on Vercel.

A member of the Team first needs to authorize it.

@tokainz
tokainz force-pushed the fix/529-inputotp-delete-key branch from d6e058b to 6648804 Compare November 16, 2026 21:59
@tokainz
tokainz force-pushed the fix/529-inputotp-delete-key branch from 6648804 to 74afae9 Compare November 16, 2026 22:02

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InputOtp: Delete key not working

1 participant