You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: input-otp, backspace in an empty box only moves focus instead of clearing the previous box #31639
I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v9.x (9.0.8, same code on main)
Current Behavior
Happens on iOS (Safari and Capacitor app, on-screen keyboard), not every time. Not reproducible in desktop browsers.
Backspace in an empty box only moves focus to the previous box without clearing it. Since focus moves to the next empty box after each typed character, the first Backspace after typing can end up deleting nothing.
Typing into the now-focused, filled box then inserts the character and shifts the rest right instead of replacing it.
The empty-box branch of onKeyDown in core/src/components/input-otp/input-otp.tsx only calls this.focusPrevious(index). It should also clear inputValues[index - 1] and its input ref, call updateValue(event), and preventDefault(). The insert-and-shift branch of onInput contradicts the documented override behavior.
Verified on 9.0.9. When Backspace is pressed in an empty box, ion-input-otp moves focus to the previous box and leaves the delete itself to the browser. Desktop browsers apply the delete to the newly focused box, but the iOS keyboard applies it to the box that was focused when the key was pressed, which is empty, so nothing gets cleared. The next character then lands in a box that still has a value.
What happens in that filled box is intended: when there is an empty box at the end, the new character is inserted and the rest shift right, and it only overrides the value when every box is filled.
Activity
thetaPC commentedon Oct 23, 2026
Thanks for the report!
Verified on 9.0.9. When Backspace is pressed in an empty box,
ion-input-otpmoves focus to the previous box and leaves the delete itself to the browser. Desktop browsers apply the delete to the newly focused box, but the iOS keyboard applies it to the box that was focused when the key was pressed, which is empty, so nothing gets cleared. The next character then lands in a box that still has a value.What happens in that filled box is intended: when there is an empty box at the end, the new character is inserted and the rest shift right, and it only overrides the value when every box is filled.
Tracked as a bug in
core.