Skip to content

Let a file tree's rows keep a glide running under their arrow keys - #7054

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-7045
Nov 24, 2026
Merged

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

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Pressing ArrowDown in the file tree while the page was still gliding to a file made the rest of the glide jump under the focused row. The cause is in scrollsFor (scrolling.js). It matched the tree's <button role="treeitem"> rows against the selector button in PLAIN_PRESSES, which says the browser scrolls for an arrow key pressed on that control. So the keyboard controller's capture listener landed the glide first (landForKey, from #6009), but the tree takes the arrow itself and the browser never scrolls. #7045's shift watch error was this scroll: on a fast machine the key arrives before the glide lands, while on CI runners it arrives after.

An element's explicit role overrides its tag's, so PLAIN_PRESSES, LINKS and RADIOS in control-selectors.js now count a native tag only where it has no role. A row in a tree, or an <a href role="tab"> in a tab list, now falls under "every other control takes those keys itself". scrollsFor is the only reader of those three selectors. This keeps #6009's rule as written: a key the browser scrolls for lands the glide, and a key a widget takes acts as it would once the glide had landed, which here means the glide goes on.

Verification:

  • Forced order. A scratch copy of test_file_tree_lands_at_the_file_start_after_reading_down pressed ArrowDown once the glide to third.md had started. Before the fix, the [document] case failed with the issue's error 2 times out of 2 on the Linux runner ("a scroll during the keydown ArrowDown on button … moved it by (0, 31)px"). With the fix it passed 3 times out of 3, the key arriving mid-glide with the glide carrying on.
  • Unit test. A new runtime test in tests/runtime/scrolling.test.mjs checks that ArrowDown and PageDown on a <button role="treeitem">, and ArrowRight on an <a href role="tab">, aren't read as browser scrolls. It fails on main and passes with the fix.
  • Other checks. The original journey test, pnpm run test:runtime (1116 pass) and pre-commit pass.

The selectors behind CONTROLS and PRESSES also match button by tag whatever its role. Nothing here showed one of their readers misreading a role-overridden button, so they are unchanged.

Closes #7045 — automated triage

…der their arrow keys

`scrollsFor` read a `<button role="treeitem">` as a plain button, which leaves
its arrow keys to the browser to scroll for. So an ArrowDown in the file tree
during a glide made the keyboard controller land the glide (`landForKey`), though
the tree takes the key itself and the browser never scrolls. The page jumped the
rest of the glide under the focused row. The suite's shift watch reported it on a
fast machine, which sends the key before the glide lands.

An element's explicit role overrides its tag's, so `PLAIN_PRESSES`, `LINKS` and
`RADIOS` now match a native tag only where it carries no role. A key a composite
widget's row takes leaves the glide running, as it would have if typed after the
glide landed.

Closes #7045
@leaf-agent
leaf-agent merged commit b47438c into main Nov 24, 2026
7 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-7045 branch November 24, 2026 19:14
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.

The file tree's landing test passes on a fast machine, as it does in CI

1 participant