Skip to content

Build a text field's editor when the user arrives in it - #3304

Merged
max-sixty merged 3 commits into
mainfrom
agent-ad86e3615bc41566d
Oct 20, 2026
Merged

max-sixty merged 3 commits into
mainfrom
agent-ad86e3615bc41566d

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

An empty leaf-text built its CodeMirror editor as it connected, so a page built one for the panel's comment field and one under every list of options before it presented, whether or not anyone wrote in them. The corpus page builds 38. An empty field now draws a box as tall as the editor's empty line and builds the editor when the user arrives in it: its own focus(), a press, native focus by any route (Tab, a test driver's focus, a right-click), a drag entering it, or a write of words. Focus that lands on the box moves into the words during the box's focusin, so the first key typed lands in them and the page hears one focusin for the field, as before. A focus handler would not do: Chrome and Firefox send no focusin for a node that passes focus on in its own focus handler. Until the editor exists, the box carries the role, name, hint and description the editor's content node would. :state(ready) now means the field draws its words, which an empty field does as it connects.

Startup on this branch against its base, in ms from navigation, the median of 7 opens per arm after a warm-up open, with the arms' order alternating each round (load average 6 to 9 on a shared Mac):

page presented presented, 4x CPU throttle upgraded, 4x
review-a-plan 173 → 165 650 → 617 563 → 524
triage-board 163 → 153 614 → 567 558 → 517
alert-review 288 → 256 1257 → 914 1145 → 794
command-hub 326 → 287 1340 → 1181 1139 → 970
corpus 4866 → 3956

First contentful paint is unchanged. Requests before presentation are unchanged except where no field is built at all: triage-board no longer fetches the Markdown renderer the editor's preview loads (48 → 47 requests, about 100 KB less). In a Chrome trace of corpus, CodeMirror construction fell from about 670 ms to 11 ms per open, and style recalculation from about 1400 ms to 860 ms.

What the user sees and does is unchanged where it was checked against base:

  • Every field's host box, its form's box, naturalBlockSize and endRoom match base at presentation on all 20 examples and the corpus.
  • Clicking, tapping, Tab, a test driver's native focus and the field's own focus() each land the next typed key in the field, in Chrome and Firefox (WebKit too, in review), and the page hears the same focus, focusin, focusout and blur sequence as base.
  • Text dropped onto an empty field lands; a right-click focuses the field and opens the context menu on the editable line, in Chrome and Firefox.
  • Chromium's accessibility tree shows the same textbox, name and placeholder before the editor is built. The box is not marked editable there, which some screen readers use to say "editable"; that has not been checked in a screen reader.

A drag passing over an empty field builds its editor even when nothing is dropped there, which costs CPU and nothing visible.

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

max-sixty and others added 3 commits October 20, 2026 02:30
An empty `leaf-text` built its CodeMirror view as it connected, so a page
paid for an editor in the panel and under every list of options before it
presented, whether or not anyone wrote in them. An empty field now draws a
box as tall as the editor's empty line and builds the editor when the user
arrives in it: its own `focus()`, a press, native focus by any route such
as Tab or a test driver's focus, or a write of words. Focus that lands on
the box moves into the words during the box's `focusin`, so the first key
typed lands in them and the page hears one `focusin` for the field, as
before. A `focus` handler would not do: Chrome and Firefox send no
`focusin` for a node that passes focus on in its own `focus` handler.

`:state(ready)` now means the field draws its words, which an empty field
does as it connects.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Words dragged onto an empty field the user had not entered landed on the
empty line's place, which took no text, so the drop was lost. A drag
entering the field now builds the editor first. Until the editor exists,
the empty line's place wears the role, name, hint and description the
editor's content node would, so assistive technology reads the same
textbox. A press of another button keeps the browser's own focus, which
lands on that place and builds the editor before a context menu reads its
target. The lint that keeps `focusin` listeners to their owners names the
field, whose empty line hands focus on in its own shadow tree.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit b0f5b4f into main Oct 20, 2026
3 checks passed
@max-sixty
max-sixty deleted the agent-ad86e3615bc41566d branch October 20, 2026 10:36
max-sixty added a commit that referenced this pull request Oct 20, 2026
…or builds (#3307)

An empty `leaf-text` builds its CodeMirror editor only when the user
arrives in it (#3304), and the box drawn in its place stood in for the
editor's content node to assistive technology. It was a textbox with the
right name, hint and description, but not an editable one: Chromium's
tree left out `editable`, which screen readers use to say "editable",
its value was empty where the editor's empty line holds a line break,
and a read-only field lost `aria-readonly` until it built.

The box now declares what CodeMirror's content node is: a multiline
textbox, `contenteditable="plaintext-only"` (CodeMirror's theme makes
its own node plain-text only), `aria-readonly` while the field is
read-only, and the same spelling, name and placeholder attributes, with
a line break in its empty line. Being editable it is a tab stop by
itself, so it drops its `tabindex`.

Each named node the field gives the accessibility tree now reads the
same before and after the editor builds:

| engine | how it was read | before this change | now |
| --- | --- | --- | --- |
| Chromium | CDP `Accessibility.getFullAXTree` | `editable` missing,
value empty | role, name, description, value and properties (`editable:
plaintext`, `focusable`, `multiline`) match |
| Firefox | its own accessibility service, through Marionette's chrome
context (Playwright's Firefox exposes no tree) | value empty, `readonly`
missing on a read-only field | role `entry`, name, description, value
and states (`editable`, `focusable`, `multi line`, `readonly`) match |

What still differs is structure inside the editor that names nothing:
CodeMirror's wrappers and its empty polite live region, which give the
host one more child once the editor is built. Neither version was
checked in a real screen reader such as VoiceOver.

Arrival is unchanged against the base in Chromium, Firefox and WebKit:
Tab, click, right-click and the field's own `focus()` each give the page
one `focus` and one `focusin` on the field, the same `selectionchange`
count, and land the next typed key in the field.

A new browser test in `tests/browser/controls/test_focus.py` tabs onto
an empty field, types a key that lands, deletes it, and compares the
field's named nodes in Chromium's tree with those it read before the
editor existed. It fails on the base.

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[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