Skip to content

fix(hub-ui): focus correct box in OtpInput after model change - #514

Open
btea wants to merge 1 commit into
devframes:mainfrom
btea:fix/otp-input-focus-next-tick
Open

btea wants to merge 1 commit into
devframes:mainfrom
btea:fix/otp-input-focus-next-tick

Conversation

@btea

@btea btea commented Dec 1, 2026

Copy link
Copy Markdown

Defer the target-box lookup in focus() to the next tick. Callers can change the model right before calling focus() (for example, clearing the code after a failed attempt), and the new prop value only arrives on re-render — reading digits synchronously focused the wrong box.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 02:48
@vercel

vercel Bot commented Dec 1, 2026

Copy link
Copy Markdown

@btea is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/514?from=github-actions[bot]

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-12-01 02:48 UTC
🔗 head 2439321
🤖 automated by pulls.review

{
  "headSha": "24393212e889a9a083cc0bc2b2668f35c949573b",
  "result": {
    "overallSummary": "Fixes a bug where `OtpInput.focus()` read the digits model synchronously, causing it to focus the wrong box when a caller cleared the code right before calling `focus()` (e.g. after a rejected OTP attempt). The lookup is deferred to the next tick, and an e2e test is added to cover this scenario.",
    "groups": [
      {
        "key": "otp-focus-fix",
        "label": "OtpInput focus fix",
        "summary": "Defer the target-box lookup in `focus()` to the next tick so it reads the model after callers clear it (e.g. after a failed OTP attempt), fixing focus landing on the wrong box.",
        "category": "ui",
        "filePaths": [
          "packages/hub-ui/src/client/components/display/OtpInput.vue"
        ],
        "critical": true
      },
      {
        "key": "e2e-test",
        "label": "E2E regression test",
        "summary": "Adds an end-to-end test verifying a rejected OTP code clears all digit boxes and refocuses the first one, covering the focus fix.",
        "category": "tests",
        "filePaths": [
          "tests/e2e/floating-dock.spec.ts"
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-12-01T02:48:53.269Z",
    "model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
    "locale": "en"
  }
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The OTP focus timing fix has no active review issues.

No open issues 🎉

What changed in this PR

Fixes OTP input focus in the hub UI when a caller changes the model immediately before calling focus(), such as after a rejected code.

Changes:

  • Defers target-box selection until the next Vue tick so it uses the updated model.
  • Adds an end-to-end regression test confirming that a rejected code clears all six boxes and refocuses the first digit.
File Description
tests/​e2e/​floating-dock.spec.ts Tests clearing and refocusing the OTP input after rejection.
packages/​hub-ui/​src/​client/​components/​display/​OtpInput.vue Waits for the model update before selecting the box to focus.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

3 participants