Skip to content

Commit 25d4dda

Browse files
author
Jaap Roes
authored
Add title attribute to icons (#8060)
## Summary Explain the meaning of the icon for screen readers (and mouse over). Hide "inactive" (low opacity) icons from screen readers. Remove opacity: 1 styling, it's the default opacity. Without this change a screen reader will just read "Hammer and spanner test tube" for the last column in each row.
1 parent 63a5a12 commit 25d4dda

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/ruff_dev/src/generate_rules_table.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>,
2222
for rule in rules {
2323
let fix_token = match rule.fixable() {
2424
FixAvailability::Always | FixAvailability::Sometimes => {
25-
format!("<span style='opacity: 1'>{FIX_SYMBOL}</span>")
25+
format!("<span title='Automatic fix available'>{FIX_SYMBOL}</span>")
26+
}
27+
FixAvailability::None => {
28+
format!("<span style='opacity: 0.1' aria-hidden='true'>{FIX_SYMBOL}</span>")
2629
}
27-
FixAvailability::None => format!("<span style='opacity: 0.1'>{FIX_SYMBOL}</span>"),
2830
};
2931
let preview_token = if rule.is_preview() || rule.is_nursery() {
30-
format!("<span style='opacity: 1'>{PREVIEW_SYMBOL}</span>")
32+
format!("<span title='Rule is in preview'>{PREVIEW_SYMBOL}</span>")
3133
} else {
32-
format!("<span style='opacity: 0.1'>{PREVIEW_SYMBOL}</span>")
34+
format!("<span style='opacity: 0.1' aria-hidden='true'>{PREVIEW_SYMBOL}</span>")
3335
};
3436
let status_token = format!("{fix_token} {preview_token}");
3537

0 commit comments

Comments
 (0)