Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-hr-presentation-role.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed [#9024](https://github.com/biomejs/biome/issues/9024). The `noInteractiveElementToNoninteractiveRole` rule no longer incorrectly flags `<hr>` elements with `role="presentation"` or `role="none"`. The `separator` role (implicit role of `<hr>`) is now treated as non-interactive, matching the WAI-ARIA spec where a non-focusable separator is a static structural element.
8 changes: 7 additions & 1 deletion crates/biome_aria_metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,19 @@ impl AriaRole {
.find_map(|value| value.parse().ok())
}

/// Returns `true` if the given role inherits of `AriaAbstractRole::Widget` and is not `Self::Progressbar`.
/// Returns `true` if the given role inherits of `AriaAbstractRole::Widget` and is not `Self::Progressbar` or `Self::Separator`.
///
/// This corresponds to a role that defines a user interface widget (slider, tree control, ...)
pub fn is_interactive(self) -> bool {
// `progressbar` inherits of `widget`, but its value is always `readonly`.
// So we treat it as a non-interactive role.
//
// `separator` inherits of both `structure` and `widget`, but it is only interactive
// when it is focusable (e.g. has `tabindex` and `aria-valuenow`).
// A non-focusable `separator` (such as `<hr>`) is a static structural element.
// See: https://www.w3.org/TR/wai-aria-1.2/#separator
self != Self::Progressbar
&& self != Self::Separator
&& self
.inherited_abstract_roles()
.contains(&AriaAbstractRole::Widget)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@
<h5 role="button" />;
<h6 role="button" />;
<hr role="button" />;
<hr role="presentation" />;
<hr role="none" />;
<img role="button" />;
<li role="button" />;
<li role="presentation" />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ expression: valid.jsx
<h5 role="button" />;
<h6 role="button" />;
<hr role="button" />;
<hr role="presentation" />;
<hr role="none" />;
<img role="button" />;
<li role="button" />;
<li role="presentation" />;
Expand Down