Skip to content

fix(OTPInput): restore the first slot's autofill capacity on clear() and reset() - #669

Merged
mrholek merged 1 commit into
v6-devfrom
fix/otp-clear-maxlength
Aug 2, 2026
Merged

fix(OTPInput): restore the first slot's autofill capacity on clear() and reset()#669
mrholek merged 1 commit into
v6-devfrom
fix/otp-clear-maxlength

Conversation

@mrholek

@mrholek mrholek commented Aug 2, 2026

Copy link
Copy Markdown
Member

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 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 situation those methods exist for: a rejected code, then a fresh one arriving by SMS.

The fix

clear() and reset() 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 when reset() 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.

…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.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 30762175117

Coverage increased (+0.008%) to 93.13%

Details

  • Coverage increased (+0.008%) from the base build.
  • Patch coverage: 2 of 2 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 9510
Covered Lines: 9083
Line Coverage: 95.51%
Relevant Branches: 5279
Covered Branches: 4690
Branch Coverage: 88.84%
Branches in Coverage %: Yes
Coverage Strength: 633.47 hits per line

💛 - Coveralls

@mrholek
mrholek merged commit cdaeecb into v6-dev Aug 2, 2026
8 checks passed
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.

2 participants