fix(web): check a radio or checkbox through its own label when the label covers it

SA
11d ago
+397-8

What and why

  • Element Plus draws el-radio-button, el-radio, and el-checkbox with the native input under the label's styled spans (opacity: 0; z-index: -1), or with no box at all (width: 0; height: 0). Playwright's hit-target check accepts only the target or its descendants, so check, uncheck, and tap on the input failed NOT_ACTIONABLE (<span class="el-radio-button__inner"> intercepts pointer events, element is not visible), and an agent step on such a radio ended AUTOMATION_UNSUPPORTED. Plain Playwright .check() fails the same way.
  • clickControl (packages/web/src/actions.ts) now clicks a native checkbox or radio through its own label when, at the input's centre, the topmost element that is the input or inside one of its labels is label content (elementsFromPoint, so a loading mask or modal on top does not change the choice), or when the input has no box (then its first rendered label). The click lands at the input's point relative to the label, so a link elsewhere in the label is not what gets pressed. Playwright's actionability checks run on the label: they wait out a mask that goes away, and anything that stays on top still fails NOT_ACTIONABLE. The input is clicked as before when it is disabled (a disabled <fieldset>'s included, :disabled), is the topmost itself, has a link, button, or other interactive element of its label at the click point (so tap never follows a link), or has its centre outside the label's box.
  • One evaluateHandle (pickStandIn) returns the label itself, under the action's deadline. While neither the control nor any of its labels is rendered (a display:none or visibility:hidden dialog not open yet), the page throws and clickControl reads again through pollCondition until the deadline, then fails NOT_ACTIONABLE: ... the control and its labels are not visible. A tap on anything else pays that one read and keeps locator.click, re-resolving, under the same deadline. The operation's signal is checked right before either click, so a read still in flight when the operation is cancelled clicks nothing. A locator that never appears still fails NOT_ACTIONABLE (tap did not become actionable in time: ... waiting for locator(...)) within one timeout.
  • setChecked keeps polling the input's checked state after the label click.
  • Holds in a shadow root (getRootNode().elementFromPoint) and inside a frame (the frame's own viewport coordinates).
await screen.getByRole('radio', '安装').check();   // was ACTION_FAILED: intercepts pointer events
await screen.getByRole('checkbox', 'Agree').check(); // was ACTION_FAILED: element is not visible

Issue

Fixes #1276

Verified

Ran it locally: yes

  • packages/web/tests/integration/check-actions.test.ts, the a control its own label covers cases, through a locator and an element handle: check and tap on each of the three Element Plus shapes; each shape behind a mask removed after 300ms and inside a display:none or visibility:hidden container shown after 300ms (the review's repros, all 14 red on f74e0e31); a modal-covered and a disabled control that must stay NOT_ACTIONABLE and unchecked; a radio whose label covers it from outside the label's box; a boxless checkbox whose first label is hidden by display or by visibility and whose second is not, and one whose every label is hidden; a radio under a link in its own label and a boxless checkbox whose label has a link at its centre, both of which must stay NOT_ACTIONABLE, unchecked, and on the same URL; a radio-button inside <fieldset disabled>; a shadow root; a frame; a tap on a locator that never appears; an action cancelled while its stand-in read is in flight, which must click nothing. On this branch: Tests 75 passed (75); the full web suite Tests 642 passed | 1 skipped (643), pnpm check green.
  • Built CLI on a scratch project whose page carries the real theme-chalk CSS for the three controls (el-radio-button.css, el-radio.css, el-checkbox.css): three tests on the settled page, and each again behind a v-loading-style mask removed after 800ms and in a display:none container shown after 800ms. node node_modules/e2e/dist/cli/bin.js run, @e2e-dev/web built from main, from the previous head, and from this branch:
mainf74e0e31 (previous head)this branch
Tests 9 failed | 0 passed (9), 180.67sTests 2 failed | 7 passed (9), 65.21sTests 9 passed (9), 7.51s
ACTION_FAILED: check did not become actionable in time: elementHandle.click: Timeout 29616ms exceeded. <span class="el-radio-button__inner">安装</span> intercepts pointer events: getByRole("radio", name: "安装")the two mask cases on radios: <span class="el-radio-button__inner">安装</span> intercepts pointer events, <span class="el-radio__inner"></span> intercepts pointer events✓ |web| tests/element-plus.e2e.ts (3 tests) 1.08s
ACTION_FAILED: check did not become actionable in time: elementHandle.click: Timeout 29626ms exceeded. element is not visible: getByRole("checkbox", name: "Agree")✓ |web| tests/late.e2e.ts (6 tests) 6.54s

Through the CLI the dialog case already passed on f74e0e31, because the role locator resolves only once the dialog is shown; the engine tests above reproduce it with raw locators and element handles.

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.

🤖 Generated with Claude Code