Skip to content

InputOTP: Auto-advance broken on Android soft keyboard (IME composition event issue) #19613

Description

@unistern

Describe the bug

On Android devices, p-inputotp does not auto-advance focus to the next input box after a character is typed.

Character (letter) input:
Focus never advances. Every character typed accumulates inside the currently focused box.
Example: typing "P" then "t" results in "Pt" in box 1 while all other boxes remain empty.

Digit input:
Auto-advance works for the very first digit only (box 1 → box 2). After that, the Android
soft keyboard switches to predictive-text / word-suggestion mode and begins injecting
composed or multi-character strings (e.g. "8ror", "4z") into the focused box.
The auto-advance logic does not trigger for these composed inputs, so multiple characters
stack in one box, some boxes are skipped, and the field ends up in a corrupted state.

Root cause hypothesis:
The auto-advance logic likely listens to keyup or input DOM events. On Android, the soft
keyboard uses an IME (Input Method Editor) that fires compositionstart/compositionupdate/
compositionend events and may batch characters before dispatching a final input event.
Single-character detection therefore fails or fires at the wrong time.

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

https://stackblitz.com/edit/xhpvqutr-5ka44f62

Environment

Device: Samsung Galaxy A52s 5G
OS: Android (Samsung One UI)
Browser: Microsoft Edge 148.0.3967.84

Angular version

20.3.18

PrimeNG version

v21

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

  1. Open the StackBlitz link on an Android device in Edge or Chrome,
    OR use Chrome DevTools → Toggle device toolbar → select a phone profile.
  2. Tap the first input box of "Test A" and type any letter.
    → All letters pile up in box 1; focus never advances.
  3. Clear the field. Tap the first box of "Test B" and type digits.
    → First digit advances correctly; from box 2 onwards digits accumulate in one box.

Expected behavior

After each single character or digit is entered, focus automatically moves
to the next input box — regardless of whether a hardware or Android IME soft keyboard is used.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Device: MobileIssue or pull request is *only* related to Mobile deviceType: BugIssue contains a bug related to a specific component. Something about the component is not working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions