Repository navigation
Build a text field's editor when the user arrives in it - #3304
Merged
Merged
Conversation
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]>
leaf-agent
approved these changes
Oct 20, 2026
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]>
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.
An empty
leaf-textbuilt 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 ownfocus(), 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'sfocusin, so the first key typed lands in them and the page hears onefocusinfor the field, as before. Afocushandler would not do: Chrome and Firefox send nofocusinfor a node that passes focus on in its ownfocushandler. 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):
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:
naturalBlockSizeandendRoommatch base at presentation on all 20 examples and the corpus.focus()each land the next typed key in the field, in Chrome and Firefox (WebKit too, in review), and the page hears the samefocus,focusin,focusoutandblursequence as base.editablethere, 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.