Skip to content

a11y/button-name: hidden controls reported as unnamed buttons #665

Closed

Description

@deniskern

Summary: squirrel 0.0.108 in HTTP mode emits a11y/button-name failures for empty buttons inside CSS-hidden, hidden, and aria-hidden ancestors. A visible unnamed button correctly fails; visible buttons named by title or aria-label pass. This concerns rule applicability, not title-based naming.

Live example: https://david-dorfmueller.de/anschlagbuchse-din-55027/DIN55027ANSCHLAGBUCHSE. The fresh sweep reports button.btn on this page and 73 others. In the current browser DOM, .js-image-zoom-out, .js-image-zoom-reset, and .js-image-zoom-in have no text/name and zero client rectangles while the image zoom overlay is closed. This establishes a hidden-control candidate; the aggregated selector is too broad to prove that every live finding identifies these buttons. A wishlist button uses title="Zum Merkzettel hinzufügen"; the isolated title control below passes, so no title fallback bug is claimed.

Reproduction: save as button-name-repro.cjs. Each case has its own origin and is audited at /, avoiding ambiguity about the origin seed and the one-page limit.

const http = require('node:http');
const cases = {
  bad: '<button></button>',
  title: '<button title="Zoom in"></button>',
  named: '<button aria-label="Zoom in"></button>',
  css: '<style>.closed{display:none}</style><div class="closed"><button></button></div>',
  hidden: '<div hidden><button></button></div>',
  aria: '<div aria-hidden="true"><button></button></div>',
};
Object.values(cases).forEach((body, index) => {
  http.createServer((req, res) => {
    res.setHeader('Content-Type', 'text/html; charset=utf-8');
    res.end('<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Button name control</title></head><body><main>' + body + '</main></body></html>');
  }).listen(8770 + index, '127.0.0.1');
});

Start node button-name-repro.cjs; in another terminal:

squirrel --version
port=8770
for name in bad title named css hidden aria; do
  squirrel audit "http://127.0.0.1:$port/" --http --refresh --offline -m 1 \
    --rule-include a11y/button-name -f json -o "$name.json"
  port=$((port + 1))
done

Actual (spark, squirrel 0.0.108, 2026-10-11 16:57 UTC / 2026-10-12 +07): bad, css, hidden, aria each produce one failed check: rule a11y/button-name, check button-name, status fail, message Buttons without accessible names. title and named each produce one passed check and issues: []. Each origin serves the same single page for any requested path; no script changes the markup. Servers and temporary reports were removed after collecting results.

Expected: keep the failure for the visible unnamed bad control and keep title/aria-label controls passing. Do not emit a proven button-name failure for an element absent from the accessibility tree. Re-evaluate naming when a closed overlay opens; a button may need a name in that future state. Off-screen controls and merely disabled buttons must not be treated as hidden. The aria case may independently violate a11y/aria-hidden-focus because the button remains focusable; that does not establish applicability of the button-name rule.

Reference: W3C ACT rule 97a4e1, applicability and Inapplicable Example 2. Related: #664 concerns CSS-hidden descendants under a11y/aria-hidden-focus, whereas this report also reproduces ignored HTML hidden and aria-hidden ancestors in a11y/button-name. No local rule suppression added.

Acceptance Criteria

  • A control with no accessible name inside a display:none/visibility:hidden ancestor, an HTML hidden ancestor, or an aria-hidden ancestor is not reported as Buttons without accessible names.
  • The visible unnamed bad fixture still fails; title and aria-label fixtures still pass.
  • Off-screen controls and merely disabled buttons are not treated as hidden.
  • The hidden-ancestor helper is shared with a11y/aria-hidden-focus (a11y/aria-hidden-focus: CSS-hidden descendants reported as focusable in HTTP mode #664).
  • Tests cover the six fixtures from the repro.

Activity

  1. added
    bug
    P2
    rules
    size: M
    on Oct 11, 2026
  2. nc9 commented on Oct 11, 2026

    @nc9
    Contributor

    Thanks Denis. Confirmed on current main: a11y/button-name has no applicability check for hidden, aria-hidden or CSS-hidden ancestors. Triaged as a bug (P2), size M, area rules. I added acceptance criteria. This shares a helper with #664 (static CSS, hidden, aria-hidden ancestors), so I'll queue them together. A visible unnamed button keeps failing, and title and aria-label controls keep passing.

  3. nc9 commented on Oct 11, 2026

    @nc9
    Contributor

    Reproduced on 0.0.108 with the repro script (ports changed). bad, css, hidden and aria each give a11y/button-name, check button-name, status fail, Buttons without accessible names. title and named pass. An extra case with an inline style="display:none" ancestor also fails.

    origin/main still has this: packages/rules/src/a11y/button-name.ts checks every button and [role='button'] with no hidden-ancestor test. The existing isHiddenFromMarkup helper in packages/parser/src/hidden-markup.ts already covers hidden, aria-hidden and inline style ancestors; the css case (a class rule in <style>) needs stylesheet support it does not have yet.

  4. nc9 commented on Oct 11, 2026

    @nc9
    Contributor

    pub#675 merged: button-name no longer reports unnamed buttons inside markup-hidden or aria-hidden ancestors, or hidden by a plainly written inline display:none or visibility:hidden. The visible unnamed button still fails, and title and aria-label buttons still pass. The case hidden by a <style> block (the css fixture) is not evaluated yet and is tracked in #678. Leaving this open until #678 lands.

  5. nc9 commented on Oct 12, 2026

    @nc9
    Contributor

    Release check 2026-10-12 (v0.0.109): the markup and inline-style paths shipped (pub#675/#676 in v0.0.109), but the criterion about hiding set by a document <style> rule is not met: that part was deliberately deferred to #678. Leaving open until #678.

  6. added a commit that references this issue on Oct 21, 2026
    21c90c0
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

    P2bugrulessize: M

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions