fix(web): list a checkbox or radio its own label draws over no box

Merged
SA
8d ago
+544-10

Stacked on #1355. This branch contains #1355's commits. Merge #1355 first, then review only the commits after dd7d3580. Without #1355, the node this PR lists can't be clicked (see Verified).

What and why

  • Element Plus shrinks its native checkbox to a 0x0 box under the box its <label> draws (.el-checkbox__original { opacity: 0; width: 0; height: 0; position: absolute; z-index: -1 }).
  • isHidden (packages/web/src/in-page/read-semantics.ts) treats a box with no size as hidden, and the walk lists only elements that are not hidden. So the agent saw box and text="Agree", with no checkbox and no checked state. A tap that ticked the box reported "No listed node changed".
  • The walk now lists a checkbox or radio that is hidden only by having no box, while a label of its own draws it (isDrawnByLabel). The node is marked not hidden, as the walk already does for a closed select's options, because agent code skips hidden nodes (packages/e2e/src/agent/reading.ts:64).
  • A tap on that node clicks the label (pickStandIn in packages/web/src/actions.ts, from #1355). So a label counts only when that click can work: it has a box of its own (not display: contents) and holds no link or other control besides its own. pickStandIn refuses a label whose centre lands on a link, so the reader rule is the stricter of the two. A checkbox under such a label stays out, as before this PR, and the agent reaches it through the label text or the drawn box.
  • The locator path is unchanged. screen.getByRole('checkbox', 'Agree') still reads the input as hidden, as Playwright's toBeVisible does.
  • Chrome's accessibility tree lists such an input, so the cross-check now agrees on the labelled ones. A shrunk control with no rendered label element still shows a person nothing and stays out. Those two cases, the display: contents label, and the label holding a link are recorded in tests/crosscheck/expected.txt with the reason.
#root document "Element Plus checkbox"
 #n2 checkbox "Agree" [checked focused]   <- was missing
 #n3 box
 #n4 text="Agree"

Issue

Fixes #1593

Verified

Ran it locally: yes

  • e2e mcp from the built packages, on the Element Plus checkbox page from #1593: observe, tap the checkbox (or the label text when no checkbox is listed), run_code expect(...).toBeChecked(), then check false and true.
main reader (#1355 head dd7d3580)this branchthis fix on main, without #1355
#n2 box, #n3 text="Agree": no checkbox#n2 checkbox "Agree"#n2 checkbox "Agree"
tap #n3: No listed node changed within the wait after this action, though toBeChecked() then passestap #n2: changed #n2 checkbox "Agree" [checked]tap #n2 failed: ACTION_FAILED: tap did not become actionable in time: elementHandle.click: Timeout 2750ms exceeded. element is not visible
check false: changed #n2 checkbox "Agree" (was: ... [checked]), check: [checked] againcheck #n2 failed: ... element is not visible
  • e2e mcp on a page with the Element Plus checkbox, the same box under a display: contents label, and an Element Plus "Accept the Terms and Conditions" label holding a link:
controlhead before review (ae1dfada)this branch (a29cc91f)
Element Plus "Agree"#n2 checkbox "Agree", tap #n2: [checked]same
display: contents label#n6 checkbox "Contents", tap #n6 failed: ACTION_FAILED: tap did not become actionable in time: the control and its labels are not visibleno checkbox node. tap on text="Contents" ticks it, toBeChecked() passes
label with a Terms link#n7 checkbox "Accept the Terms and Conditions", tap #n7 failed: ACTION_FAILED: ... element is not visibleno checkbox node. tap on the drawn box ticks it, toBeChecked() passes. A tap on the label text lands on the link (path /#went), as on main
  • check-actions.test.ts taps every checkbox or radio an observation lists over no box, so a reader rule that lists one the tap refuses fails it. Removing any guard in isDrawnByLabel (visibility, skipped content of a slotted input, the type check, display: contents, the link check, the control's own exclusion) fails at least one test.
  • The cross-check fixture controls drawn by their label failed before the fix with five chrome missing lines and passes after it with the two recorded ones. The benchmark cross-check (CROSSCHECK_BENCHMARK_URL) passes too, so no benchmark scenario's tree moved.
  • read-node-checked.test.ts fails without the hidden = false override (expected true not to be true).
  • The web-benchmark agent suite (--strict-cache, CI=1) has the same 7 failures on dd7d3580 and on this branch. All 7 need a model call, and there was no AI_GATEWAY_API_KEY locally.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved

šŸ¤– Generated with Claude Code