Skip to content

fix: filter hidden elements to prevent strict mode violations#841

Merged
stevez merged 1 commit into
mainfrom
fix/strict-violation-visibility-filter
Apr 26, 2026
Merged

fix: filter hidden elements to prevent strict mode violations#841
stevez merged 1 commit into
mainfrom
fix/strict-violation-visibility-filter

Conversation

@stevez

@stevez stevez commented Apr 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • When locators match both visible and hidden elements (e.g. a visible <label> and a cdk-visually-hidden <input> sharing the same aria-labelledby), strict mode throws
  • Now filters to visible elements before acting, consistent with chainAction and actionByRole which already had this logic
  • Functions fixed: actionByText, checkByText, uncheckByText, pressKey, pressKeyByRole, dragDrop

Context

Discovered while testing Rogers MyRogers bill download — their design system uses visually-hidden native checkboxes alongside visible label elements with matching aria-labelledby. check "January 24, 2026" failed with strict mode violation (2 elements matched).

Test plan

  • check "January 24, 2026" on Rogers Save PDF modal — no strict violation
  • check "February 24, 2026" — no strict violation
  • Screenshot confirms all checkboxes correctly checked
  • Verify click, press, drag still work on single-element locators (no regression)

🤖 Generated with Claude Code

When locators match both visible and hidden elements (e.g. a visible
<label> and a cdk-visually-hidden <input> sharing the same accessible
name), strict mode throws. Now filters to visible elements before
acting, consistent with chainAction and actionByRole which already
had this logic.

Functions fixed: actionByText, checkByText, uncheckByText, pressKey,
pressKeyByRole, dragDrop.

Discovered while testing Rogers MyRogers bill download — their design
system uses visually-hidden native checkboxes alongside visible label
elements with matching aria-labelledby.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@stevez
stevez merged commit af8cd41 into main Apr 26, 2026
8 checks passed
@stevez
stevez deleted the fix/strict-violation-visibility-filter branch April 26, 2026 18:31
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.

1 participant