Skip to content

fix(frontend): removing a plan account chip by keyboard drops focus to body #1648

Closed

Description

@cristim

Summary

In the plan modal, removing an account chip with the keyboard drops focus to <body>.

Current behaviour

The remove button's click handler calls renderPlanAccountChips(), which clears the container and rebuilds it, destroying the focused button (frontend/src/plans.ts, renderPlanAccountChips, ~line 1285-1305).

Steps to reproduce

  1. Open the plan modal with at least two selected accounts.
  2. Tab to a chip's remove button and press Enter.
  3. Observe document.activeElement is <body>.

Expected behaviour

Focus moves to the next chip's remove button, the previous one, or the account search input when none remain.

Proposed fix

After re-render in the remove handler in frontend/src/plans.ts, focus the neighbouring chip's remove button or #plan-account-search.

References

Discovered while reviewing #1600.

Severity

low

Activity

  1. cristim commented on Nov 10, 2026

    @cristim
    MemberAuthor

    Claimed by claude-ui-fix-1 (fleet). Premise re-checked on main: the remove button's click handler in renderPlanAccountChips (frontend/src/plans.ts ~:1361) re-renders the chip container and destroys the focused button, so document.activeElement falls to body. Plan: remember the removed chip's index, re-render, then focus the chip now at that index (the next one), else the last remaining one, else #plan-account-search; jest tests for each case in plans.test.ts. Test-first, two cold staged-diff review passes, then one PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions