fix(web): check a radio or checkbox through its own label when the label covers it
SA
11d ago+397+397+012345678901234567890123456789-8-8-0123456789
What and why
- Element Plus draws
el-radio-button,el-radio, andel-checkboxwith 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, socheck,uncheck, andtapon the input failedNOT_ACTIONABLE(<span class="el-radio-button__inner"> intercepts pointer events,element is not visible), and an agent step on such a radio endedAUTOMATION_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 failsNOT_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 (sotapnever 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 (adisplay:noneorvisibility:hiddendialog not open yet), the page throws andclickControlreads again throughpollConditionuntil the deadline, then failsNOT_ACTIONABLE: ... the control and its labels are not visible. A tap on anything else pays that one read and keepslocator.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 failsNOT_ACTIONABLE(tap did not become actionable in time: ... waiting for locator(...)) within one timeout. setCheckedkeeps 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, thea control its own label coverscases, 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 adisplay:noneorvisibility:hiddencontainer shown after 300ms (the review's repros, all 14 red on f74e0e31); a modal-covered and a disabled control that must stayNOT_ACTIONABLEand unchecked; a radio whose label covers it from outside the label's box; a boxless checkbox whose first label is hidden bydisplayor byvisibilityand 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 stayNOT_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 suiteTests 642 passed | 1 skipped (643),pnpm checkgreen.- 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 av-loading-style mask removed after 800ms and in adisplay:nonecontainer shown after 800ms.node node_modules/e2e/dist/cli/bin.js run,@e2e-dev/webbuilt from main, from the previous head, and from this branch:
| main | f74e0e31 (previous head) | this branch |
|---|---|---|
Tests 9 failed | 0 passed (9), 180.67s | Tests 2 failed | 7 passed (9), 65.21s | Tests 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/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.
🤖 Generated with Claude Code