Skip to content

Commit

Permalink
Remove labelledby from Icon and set its aria-hidden to be the default
Browse files Browse the repository at this point in the history
  • Loading branch information
piqusy committed Dec 6, 2024
1 parent 3129455 commit 54eaac2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
- Fix Image component responsive output Co-authored-by: [email protected]
- Add "Auto" width to wrapperContent and set is as defaults
- Add a buttonType attribute to Button component
- Implement a11y for Icon component either by setting aria-hidden to true or using the existing iconName label from manifest option key
- Implement a11y for Icon component either by setting aria-hidden to true (default) or using the existing iconName label from manifest options key
- Updated dependencies.

## [1.4.6]
Expand Down
8 changes: 1 addition & 7 deletions blocks/init/src/Blocks/components/icon/icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@
}

if (!empty($iconTitle)) {
$uniqueId = Helpers::getUnique();
$titleId = esc_attr("{$iconName}_title_{$uniqueId}");

$ariaLabelledby = 'aria-labelledby="' . $titleId . '"';
$titleTag = '<title id="' . $titleId . '">' . esc_html($iconTitle) . '</title>';

$icon = str_replace('<svg ', '<svg ' . $ariaLabelledby . ' ', $icon);
$titleTag = '<title>' . esc_html($iconTitle) . '</title>';
$icon = str_replace('</svg>', $titleTag . '</svg>', $icon);
}
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/init/src/Blocks/components/icon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"iconAriaHidden": {
"type": "boolean",
"default": false
"default": true
}
},
"options": {
Expand Down

0 comments on commit 54eaac2

Please sign in to comment.