Skip to content

web: check() and tap() fail on a Tailwind sr-only checkbox inside its own label #1744

Open

Description

@abhinavapasok

What happened

check() and tap() can't operate a checkbox styled with Tailwind's sr-only inside its own label, which is the usual toggle-switch markup (Flowbite and most Tailwind kits; Bootstrap's visually-hidden is the same CSS):

<label>
  <input type="checkbox" class="sr-only">
  <div class="track"></div>
  <span>Email notifications</span>
</label>
await screen.getByRole('checkbox', 'Email notifications').check();
ACTION_FAILED: check did not become actionable in time: elementHandle.click: Timeout 29684ms exceeded. <div class="track"></div> intercepts pointer events: getByRole("checkbox", name: "Email notifications")

tap() fails the same way, and so does an sr-only checkbox in a label that holds only text (<span> intercepts). check({ force: true }) is rejected with INVALID_ARGUMENT, so there is no workaround in the test.

Expected: the checkbox is checked through its label, as docs/reference/screen.mdx says under check: "a checkbox or radio hidden under its own label ... is clicked through that label."

Reproduction

https://github.com/abhinavapasok/e2e-repros/tree/main/sr-only-toggle

Steps to reproduce

  1. cd sr-only-toggle && npm install
  2. npx e2e run
  3. All three tests fail with ACTION_FAILED ... intercepts pointer events. Expected them to check the box.

Versions

e2e 0.23.0, @e2e-dev/web 0.15.5, node 24.17.0, macOS. Also fails on the 2026-11-13 nightly (e2e 0.23.1-nightly, @e2e-dev/web 0.16.0-nightly).

Engine

@e2e-dev/web

Anything else

A follow-up to #1276. On the nightly, removing only margin: -1px from .sr-only makes all three pass, so the stand-in from #1595 works but misses this case. In pickStandIn (packages/web/src/actions.ts:143), the label is used only when the control's centre lies inside the label's rect. sr-only's margin: -1px puts the 1×1 input's centre just outside the label's left edge, so it returns null and the click goes to the hidden input.

I'd like to work on the fix.

Activity

  1. okwasniewski commented on Nov 13, 2026

    @okwasniewski
    Member

    [claude-opus-5-5] automated review on behalf of @okwasniewski

    Thanks, confirmed on main: the 1x1 sr-only input's centre (x=7.5) lands half a pixel left of the label (x=8), so pickStandIn (packages/web/src/actions.ts) refuses the label stand-in and the click goes to the clipped input. Plain Playwright check() fails the same way. Fix in progress in #1748.

  2. added
    bugSomething isn't working
    webWeb engine (@e2e-dev/web)
    P2Improvement / follow-up
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Improvement / follow-upbugSomething isn't workingwebWeb engine (@e2e-dev/web)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions