Repository navigation
fix(input-otp): clear the previous box when backspace is pressed in an empty box - #31651
Open
sarankumar1325 wants to merge 1 commit into
Open
sarankumar1325 wants to merge 1 commit into
sarankumar1325 wants to merge 1 commit into
Conversation
|
@sarankumar1325 is attempting to deploy a commit to the Ionic Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #31639
What is the current behavior?
Pressing Backspace in an empty
ion-input-otpbox only callsfocusPrevious()and leaves the delete to the browser's default action. Desktop browsers apply that delete to the newly focused box, but the iOS keyboard applies it to the box that had focus when the key was pressed, which is empty. So on iOS the previous box keeps its value, and the next character lands in a filled box (for example789, Backspace,6gives7869instead of786).What is the new behavior?
inputValues,previousInputValues), emitsionInputthroughupdateValue(), moves focus back, and callspreventDefault(). This matches the documented keyboard interaction ("In an empty box: moves focus back one box and clears its value") on every platform, without depending on where the browser applies the default delete.input-otp.spec.ts. The spec environment doesn't apply the browser's default Backspace action, like the iOS keyboard, so the first test fails onmain(box 3 still holds9) and passes with this change.Does this introduce a breaking change?
Other information
The insert-and-shift behaviour in a filled box is unchanged, since it is intended (as noted on the issue).
Tests:
npx stencil test --spec -- src/components/input-otp(2 passed; the first fails on main), eslint and prettier on the changed files.This change was prepared with the help of an AI coding assistant; I reviewed it and ran the tests above.