Skip to content

Read an empty text field as the same editable textbox before its editor builds - #3307

Merged
max-sixty merged 1 commit into
mainfrom
agent-a1e5c2b8820cfe1ea
Oct 20, 2026
Merged

max-sixty merged 1 commit into
mainfrom
agent-a1e5c2b8820cfe1ea

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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

…or builds

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, compared in Chromium through
CDP and in Firefox through its own accessibility service:

- Chromium: the content textbox's role, name, description, value and
  properties (`editable: plaintext`, `focusable`, `multiline`) match;
  before this change `editable` was missing and the value was empty.
- Firefox: role `entry`, name, description, value and states
  (`editable`, `focusable`, `multi line`, and `readonly` for a read-only
  field) match; before, the value was empty and `readonly` was missing.

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 was checked in a
real screen reader.

A new browser test 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.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 130e95f into main Oct 20, 2026
3 checks passed
@max-sixty
max-sixty deleted the agent-a1e5c2b8820cfe1ea branch October 20, 2026 11:07
leaf-agent added a commit that referenced this pull request Nov 19, 2026
…tarea from #6383 (#6453)

#6383 stands the floating panel's row from the first paint and makes an
unbuilt text field's box a textarea. Three main-tier tests still
asserted the earlier behavior, and each one failed on `main`. This PR
updates the tests to match #6383 and changes no product code. Each test
fails on `main` (`c865c3e99`) and passes on this branch, run with `uv
run pytest <node id> -n 0`.

- **`test_startup_continues_while_the_registry_fetch_is_held`** asserted
that no panel stands while the registry fetch is held. Now the panel
there is the row the document served (`data-lf-served`), which #6383
meant to show. The test asserts that instead, so it still checks that
the runtime's panel hasn't mounted.
-
**`test_an_empty_field_reads_the_same_before_and_after_its_editor_builds`**
compared the accessibility nodes exactly. An empty textarea gives the
tree no value, while CodeMirror's empty line reads `'\n'`, and a
textarea reports `invalid: false`. Those two differences are the whole
failure. The textarea still matches the editor on role, name,
description, `editable`, `focusable`, `multiline`, `readonly` and
`required`, which are what #3307 made the test check. The test now holds
the field's editable node to its exact empty value: Chromium's tree
gives the empty textarea no value at all, and the built editor's empty
document one line break (`'\n'`), so a field holding several blank lines
no longer passes. It ignores `invalid: false` and still compares every
other node and property before and after. No screen reader was run; the
docstring describes the observed tree.
- **`test_firefox_s_copy_of_a_group_builds_no_add_field`** no longer
reached the case it guards. In both commits, Firefox's selection at
mouseup sits in the add field's shadow root, at the placeholder text.
Before #6383, `cloneContents()` on it threw `HierarchyRequestError`.
With the textarea, it clones without error. I tried the same drag on
this commit after the field's editor had built (an editable node is back
in the shadow root), and it throws again. So the `inWindowDocument`
guard in `widget-upgrade.js` and `leaf-element.js` is still needed. The
test now focuses the field and releases focus before the drag, which
brings the guarded case back.

Closes #6451 — 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