Skip to content

Land a press on a tab panel's contents where it would land without the panel's stop - #6353

Merged
max-sixty merged 2 commits into
mainfrom
click-c-comment-target
Nov 18, 2026
Merged

max-sixty merged 2 commits into
mainfrom
click-c-comment-target

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A click on empty space or words in an open tab panel focused the panel, because its tabindex=0 makes it click-focusable. c then commented on the whole tab ("Comment on tab · #6312 …"), and no ring showed it. Now the press lands where it would without the panel's stop: on the nearest other focusable box around the panel, or nowhere. So c gives "Comment on the page", as it does on a plain page. Tabbing onto the panel still puts the user on it.

Worth weighing:

  • DOM focus stays on the panel until the release, because Chromium ends a drag's selection when focus moves mid-drag. Until then, focused(), holds and the focus paint read where the press will land.
  • A tap's focus arrives at its click, so it passes a task later; otherwise Chromium drops the caret.
  • WebKit drops a collapsed caret on blur, so the caret is put back.
  • The stop that reach.js lends an overflowing box keeps its press focus, because a click on a diff's or a code block's scrollport is what puts the user in that widget's keys. So a click on a wide table still makes c comment on the table, at widths where the table overflows.

Max asked for this on a Leaf page. Codex and a fresh Claude Code agent each reviewed it.

Tests:

  • New focus.test.mjs cases cover each route.
  • 418 focused browser tests pass.
  • leaf-dev probe, base against head: Chromium, Firefox and WebKit, plus Chromium touch.

This was written by Claude Code on behalf of max-sixty

…e panel's stop

The open tab panel takes tabindex=0 so the keyboard can reach and scroll it, and the
browser focuses the nearest focusable box around a press. So a click on a panel's words
or empty space focused the panel, with no ring, and `c` then commented on the whole tab
("Comment on tab · #6312 …") where a plain page gives "Comment on the page".

focus.js now passes that focus on at the release: to the nearest other box around the
panel that a press focuses, or nowhere. Until the release, DOM focus stays on the panel
so a drag still selects, while `focused()`, holds and the focus paint read where the
press will land. The same holds when the keyboard had put the user on the panel, and
when the pressed control takes no focus of its own (a button in WebKit). A tap, whose
focus arrives at its click, passes a task later so Chromium keeps its caret. A key or
placement during the press takes over. WebKit's dropped caret is put back.

Reach's lent stop on an overflowing box keeps its press focus: a diff's or a code
block's scrollport wears it, and a click on a widget's contents is what puts the user
in its keys.

Measured with `leaf-dev probe` on a copy of the needs-me queue page, base against head,
in Chromium and Firefox: click on empty space or words then `c` went from "Comment on
tab" to "Comment on the page"; a drag still comments on the selection; PageDown and `d`
still scroll the panel (588 px, 444 px); Tab onto the panel then `c` still comments on
the tab. In WebKit a button press in a panel now gives a page comment too, and Chromium
touch taps keep the caret and PageDown.
@max-sixty
max-sixty merged commit e9d9c4a into main Nov 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the click-c-comment-target branch November 18, 2026 07:29
leaf-agent added a commit that referenced this pull request Nov 18, 2026
)

#6353 changed where a press on an open tab panel's contents lands. It
now goes to the nearest other focusable box around the panel, or
nowhere, instead of focusing the panel through its `tabindex=0`.
`test_a_preview_leaves_a_region_the_user_works_in_reachable[panel-*]`
still proved that the press reached the panel by expecting the panel to
take focus. It failed on main in push run
[44269587200](https://github.com/max-sixty/leaf/actions/runs/44269587200),
in Chromium and Firefox, with `#region` inactive.

The test checks that a margin preview doesn't cover a region the user
works in. For the panel case it now checks that the click itself landed
on `#region`. A preview covering that point would have received the
click, so the check still fails in that case. The code and frame cases
keep their focus checks, since #6353 leaves both alone: the code is a
scroll stop Leaf lends, and the frame's field takes focus. Only the test
changes, and #6353's behavior stays as its author intended.

Verification: both panel cases fail on main locally with the CI message.
All six cases of the test pass on this branch.

Refs #3985 — automated triage

Co-authored-by: leaf-agent <[email protected]>
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.

2 participants