Skip to content

BUGFIX: template-no-redundant-role — use input type to determine implicit role - #2873

Merged
NullVoxPopuli merged 2 commits into
ember-cli:masterfrom
HawkForge:fix/no-redundant-role-input-type
Oct 29, 2026
Merged

NullVoxPopuli merged 2 commits into
ember-cli:masterfrom
HawkForge:fix/no-redundant-role-input-type

Conversation

@HawkForge

Copy link
Copy Markdown
Contributor

Fixes #2856. Thanks to @BoussonKarel for the report.

The rule mapped roles to tag names only (spinbutton: ['input'], etc.) and ignored type. So <input type="text" role="spinbutton"> was reported and autofixed away, although the implicit role of that input is textbox, not spinbutton.

This adds getInputImplicitRole, in the same shape as the existing getSelectImplicitRole. It derives the implicit role from a static type, per HTML-AAM:

  • absent, invalid, text, email, tel, url → textbox
  • search → searchbox, number → spinbutton, range → slider
  • checkbox → checkbox, radio → radio
  • button, submit, reset, image → button
  • a list attribute on a text or search input → combobox
  • password, hidden, date and the like → no implicit role

The role is only reported when it equals that implicit role. A dynamic type or list skips the report, so there is no autofix in that case.

Tests (gjs and hbs): spinbutton and searchbox on type="text", slider on type="number", role="checkbox" without a type, a dynamic type, and textbox with list are now valid. spinbutton on type="number" and textbox with no type are still reported and fixed. The new valid cases fail without the fix.

  • vitest run tests/lib/rules/template-no-redundant-role.js: 89 passed; with only the rule change reverted, the 12 new valid cases fail.
  • Full suite: 269 files, 9811 tests passed.
  • eslint and prettier clean on the changed files.

Replaces #2871, which got closed when my fork was accidentally detached.

@NullVoxPopuli
NullVoxPopuli merged commit 5193469 into ember-cli:master Oct 29, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

template-no-redundant-role: false positive for role on <input> whose implicit role differs (e.g. spinbutton on type="text"), and the autofix removes it

2 participants