Skip to content

fix: mm click on a visually hidden checkbox or radio clicks its label instead of timing out - #108

Open
seaona wants to merge 1 commit into
mainfrom
fix/click-hidden-checkbox-label
Open

seaona wants to merge 1 commit into
mainfrom
fix/click-hidden-checkbox-label

Conversation

@seaona

@seaona seaona commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Description

Toggle components keep the real <input type="checkbox">, and its data-testid, as a 1×1 screen-reader-only element under decorative divs. In MetaMask, ToggleButton (built on react-toggle-button) passes dataTestId to that input, so mm click --testid basic-functionality-toggle targets an element a user can't click. Playwright's hit-target check keeps failing with <div>…</div> intercepts pointer events and retries until the timeout. The click waits the full 15 s and then fails with MM_CLICK_TIMEOUT, and agents fall back to CDP element.click() workarounds.
When the click target is a checkbox or radio no larger than 1 px on either side, the browser driver now clicks the input's label instead (a wrapping <label> or a single <label for="<id>">). That toggles the input the way a user does, and the result includes clickedLabel: true.

  • New findLabelForHiddenControl() in src/tools/utils/hidden-control.ts. It uses only Playwright locator calls (boundingBox, count, getAttribute, chained xpath= locators), with no page scripts, so it works where LavaMoat restricts scripts in the page.
  • PlaywrightPlatformDriver.click() clicks the label when one is found. The abort check, the "page closed after click" result, the missing-target fail-fast and the error classification are unchanged.
  • clickedLabel?: boolean added to ClickActionResult and ClickResult.
  • Documented in SKILL.md and the README tools table.
    Out of scope: a hidden input with no label is still clicked as before and times out; there's no visible element we could safely click on the user's behalf. Inputs hidden with display: none or a 0×0 box still fail the visibility wait as they do today.

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/AIENG-270

Screenshots

Found here

image
  • Red circle: where the sits. It measures 1×1 px with clip: rect(0px, 0px, 0px, 0px).
  • Orange dashed box: the settings row
    that is on top of that point, which is why Playwright reports "intercepts pointer events".
  • Green box: the , which is clickable. This is what the fix clicks.
  • Dark banner: the command I ran and the error it returned (Click timed out after 5000ms). I passed --timeout 5000 to save time; without it the click waits the full 15 s.

Manual testing steps

  1. Start a browser session on a MetaMask build and open Settings → Security & privacy.
  2. Run mm click --testid basic-functionality-toggle.
  3. The command returns right away with "clickedLabel": true, and the Basic Functionality modal opens. Before this change it waited 15 s and failed with MM_CLICK_TIMEOUT (<div> intercepts pointer events).
  4. Run mm click on a normal button or visible checkbox. It is clicked directly, with no clickedLabel field.

Also checked in Chromium against a page reproducing the react-toggle-button DOM:

  • The toggle input measures 1×1. Its label is clicked in about 70 ms and toggles exactly once per click.
  • A <label for> checkbox works, including an id that contains quotes.
  • A visible checkbox is still clicked directly.
  • A hidden input with no label still times out.

@seaona
seaona marked this pull request as ready for review November 18, 2026 13:57
@seaona
seaona requested a review from a team as a code owner November 18, 2026 13:57

This branch has not been deployed

No deployments
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