fix(OTPInput): restore the first slot's autofill capacity on clear() and reset() - #669
Merged
Conversation
…and reset() `_syncFirstInputMaxLength()` ran on init and after a distributed code, but not from the public `clear()` / `reset()`. So once the field had been filled, the first slot kept `maxlength=1` and the next code delivered by SMS autofill or a password manager was truncated to a single character again — exactly the case those methods exist for (a rejected code, then a fresh one). Found while backporting #665 to the v5 line, where the same gap was fixed at the same time. Two regression tests, both red before the fix.
Coverage Report for CI Build 30762175117Coverage increased (+0.008%) to 93.13%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
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.
Follow-up to #665, found while backporting it to the v5 line.
The gap
_syncFirstInputMaxLength()runs on init and after a distributed code, but never from the publicclear()/reset(). So once the field had been filled, the first slot keptmaxlength=1, and the next code delivered by SMS autofill or a password manager was truncated to a single character again — exactly the situation those methods exist for: a rejected code, then a fresh one arriving by SMS.The fix
clear()andreset()call_syncFirstInputMaxLength(), which sizes the first slot in both directions — back up to the slot count when it ends up empty, down to one character whenreset()restores a configured value.Tests
Two regression tests, both red before the fix. Full unit suite green (64 in
otp-input.spec.js), eslint clean.v5
The same gap was fixed on the v5 line in #668 (merged), together with the #665 backport, so the two lines stay in sync.