Repository navigation
fix: paint the keyboard focus mark at keydown so a key-closed diff fold skips its motion - #5688
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#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-visibleto Leaf'sdata-lf-focus-visiblemark, to cut restyle cost. Butfocus.jsrepainted that mark only in asetTimeoutafter a keydown. A summary focused by a click and then closed with Enter has no focus event; native:focus-visibleswitches on at the key, while the mark arrived a task later. So the fold had already started its full transition, and dropping the duration to0safterwards didn't stop the running transition. The test's stretched timeline then held the fold at its halfway height (85.95 == 85.95in 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-visiblechanges. #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.ring/focus_ring/focus_visiblepass.Closes #5659 — automated triage