fix(breadcrumb): give the icon-only home link an accessible name - #1406
Open
rene-schakmann wants to merge 1 commit into
Open
fix(breadcrumb): give the icon-only home link an accessible name#1406rene-schakmann wants to merge 1 commit into
rene-schakmann wants to merge 1 commit into
Conversation
The home item always renders an icon, but `homeAriaLabel` had no default,
so `[attr.aria-label]` resolved to `undefined` and was never rendered. When
`home` carries no `label`, the link ended up with no accessible name: axe
reported a `link-name` violation (WCAG 2.4.4 / 4.1.2) and screen readers
announced only "link".
The home link now falls back to the new `aria.home` translation key
("Home" by default) instead of hardcoded English, so the label can be
localized through the locale configuration. An explicit `homeAriaLabel`
still wins, and the fallback is skipped when `home.label` is set so a
visible label is never overridden by an aria-label.
Fixes openng-org#1403
|
@rene-schakmann, I checked this in an isolated working environment: I extracted the branch, compiled The precedence in It seems fine to me. cc @geromegrignon, FYI since this follows up on the #57 thread. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect Fix
Fixes #1403
Problem
Breadcrumb always renders an icon for the home item (either
home.iconor the built-in SVG), buthomeAriaLabelhad no default.[attr.aria-label]="homeAriaLabel"therefore resolved toundefinedand the attribute was never rendered.With the default icon-only pattern (
home = { icon: 'pi pi-home' }, as used by the Basic demo) the link ends up with no accessible name:link-nameviolation (WCAG 2.4.4 / 4.1.2)link ""Solution
The home link now falls back to a new
aria.hometranslation key ("Home"by default) instead of hardcoded English, so the label is localizable through the locale configuration, consistent with how the other components resolve their aria labels.Precedence:
homeAriaLabelwhen provided — unchanged behaviouraria.hometranslation, but only whenhome.labelis not setThe second condition matters: when the home item has a visible label, that label already names the link, and adding an
aria-labelwould override it (WCAG 2.5.3 Label in Name). So the fallback only kicks in for the icon-only case that actually lacks a name.Changes
packages/optimus-ui/src/api/translation.ts— addhome?: stringto theAriainterfacepackages/optimus-ui/src/config/optimus.ts— defaultaria.hometo'Home'packages/optimus-ui/src/breadcrumb/breadcrumb.ts— resolve the home link'saria-labelthrough ahomeLinkAriaLabelgetter (both thehrefand therouterLinkanchor)packages/optimus-ui/src/breadcrumb/breadcrumb.spec.ts— tests for the default translation, a configured translation,homeAriaLabelprecedence, and the visible-label caseapps/docs/doc/breadcrumb/accessibility-doc.ts— document how the home link is namedapps/docs/doc/configuration/locale/apidoc.ts— document thearia.homekeyVerification
ng test optimus-ui --include='**/breadcrumb/*.spec.ts'→ 89/89 passing (4 new).Prettier and lint clean on the touched files.
The generated API docs (
apps/docs/doc/apidoc/index.json,apps/docs/public/llms/**,apps/docs/api-generator/typedoc.json) are left untouched since they are produced bybuild:docs:content.Breaking Changes
None. Consumers that already set
homeAriaLabelorhome.labelare unaffected; only the previously unnamed icon-only link gains a name.🤖 Generated with Claude Code