Skip to content

fix(app): release focus after immediate mobile drawer dismissal #97

Closed

Description

@trmosala

Description

Dismissing the mobile model-variant drawer immediately after opening can leave keyboard focus trapped in its offscreen content. The trigger reports aria-expanded="false", but focus does not return after ten seconds. This is separate from the composer overflow-layout checks in #96.

Reproduced in the real production component at 9612daf82d96ab0d38cb9ed41205c8a58de26df1, with Corvu drawer 0.2.4. A full component run had four such failures; a focused diagnostic run reproduced two failures in six cases. At failure the drawer's transform was matrix(1, 0, 0, 1, 0, 162), no animations were active, and the variant trigger remained unfocused. Before Escape, affected runs could still have the entire drawer below the viewport.

Steps to reproduce

From packages/app at the revision above, with the repository's Playwright Chromium installed:

CI=1 bun run test:components composer.spec.ts --grep 'scrolls overflowing' --workers=2 --retries=0

The regression opens the variant picker with Enter at a 360px viewport, observes the option in the DOM and immediately presses Escape. Repeat if the timing does not reproduce on the first run.

Expected: the drawer closes and returns focus to the variant trigger, including when dismissal precedes the opening paint.

Actual: the drawer can stay logically present and retain focus after its trigger says it is closed.

Source and verification

Production select, drawer wrapper, original keeper.

The installed Corvu implementation defers opening with afterPaint and completes animated closing on transitionend. An opening/closing race is suspected; its precise cause is not proven. No production fix is claimed. #96 makes the normal layout test wait until the option is fully in view; that setup change does not qualify immediate dismissal.

Acceptance criteria and verification

  • Escape before the first opening paint closes the drawer and returns focus.
  • Repeated open/close cycles remain usable with normal and reduced motion.
  • Preserve ordinary keyboard selection, mobile animation and focus return.
  • Add a focused regression that controls the initial-paint boundary, fails before the fix and passes afterward without arbitrary sleeps.

OpenCode version

CookieMonster V2 source 9612daf82d96ab0d38cb9ed41205c8a58de26df1.

Operating System

Linux amd64, repository Playwright Chromium. The installed CM was not modified or restarted.

Activity

  1. trmosala commented on Oct 21, 2026

    @trmosala
    OwnerAuthor

    Merged into CM-Split-v2 as 290d7d6353c0c7a4a356af780b5687f2dcfe5cfc through PR #96. Its tree exactly matches reviewed source 68ab9205709350385471eb2d383b3cff3c18e678.

    Implemented in PR #96, reviewed source 68ab9205709350385471eb2d383b3cff3c18e678.

    The Corvu drawer patch prevents a stale opening callback from reopening a dismissed drawer and completes dismissal when no closing animation exists. Both JS and Solid JSX exports are patched. The normal-motion regression fails before the patch; normal/reduced-motion and repeated keyboard cycles pass afterward. Exact geometry assertions await menu focus/scroll restoration without increased tolerance or timeout.

    Final verification is deferred at the user's explicit request to finish and close the implementation issues before one final test pass. This closure records implementation completion, not a claim that the final combined/platform checks have passed. Any failure in that pass will be recorded against the relevant issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions