Skip to content

fix: paint the keyboard focus mark at keydown so a key-closed diff fold skips its motion - #5688

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-5659
Nov 7, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-5659

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

#5479 moved the diff package's rule that a fold closed from the keyboard skips its motion (packages/diff/styles/disclosure.css) from native :focus-visible to Leaf's data-lf-focus-visible mark, to cut restyle cost. But focus.js repainted that mark only in a setTimeout after a keydown. A summary focused by a click and then closed with Enter has no focus event; native :focus-visible switches on at the key, while the mark arrived a task later. So the fold had already started its full transition, and dropping the duration to 0s afterwards didn't stop the running transition. The test's stretched timeline then held the fold at its halfway height (85.95 == 85.95 in the failure).

The keydown listener now also queues the focus paint, so the mark lands when the listener ends, before the key's default action runs. That is the same moment native :focus-visible changes. #5479's intent stays as it was (rules read Leaf's marks, not native focus), and keyboard closes are instant again. A repaint with unchanged focus walks only the focused node's ancestry, so a keystroke pays nothing that grows with the page.

Verified locally:

  • test_evidence_close_folds_room_but_retires_controls_immediately: [browser-call] and [browser-file] fail on main and pass with this change. The two Firefox cases also pass.
  • pnpm run test:runtime: 896 pass.
  • 167 browser tests matching ring / focus_ring / focus_visible pass.

Closes #5659 — automated triage

…ld skips its motion

#5479 moved the diff package's "close at once from the keyboard" rule from
native `:focus-visible` to Leaf's `data-lf-focus-visible` mark. focus.js
repainted that mark only in a timeout after the key, so a summary focused
by a click and closed with Enter started its full fold transition before
the mark arrived, and the fold stayed mid-motion. The mark now repaints
once the keydown listener ends, before the key's default runs, as native
`:focus-visible` already changed. Restores the instant keyboard close that
test_evidence_close_folds_room_but_retires_controls_immediately protects.

Closes #5659
@leaf-agent
leaf-agent merged commit 76c9c08 into main Nov 7, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5659 branch November 7, 2026 22:44
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.

test_evidence_close_folds_room_but_retires_controls_immediately fails on main since #5479 halved a Tab's cost

1 participant