Repository navigation
Conversation
The aria-label host binding wrote null when igxLabel was unset, which removed any aria-label the template set (regression from #17155). The button now writes aria-label only through igxLabel and restores the element's own value when igxLabel is cleared. Label styles now skip .igx-button, so igxLabel on a button no longer gets the IgxLabelDirective styles. The button's igxLabel input is deprecated in favor of aria-label. Closes #18009
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Clearing igxLabel can overwrite or remove a newer native aria-label, leaving an incorrect accessible name; restoration must check attribute ownership and include a regression test.
1 open issue
What changed in this PR
Backports the button accessibility and styling fixes from #18055 to 22.2.x, addressing native aria-label removal and the label-color regression reported in #18009.
Changes:
- Replaces the button’s
aria-labelhost binding with targeted attribute updates and adds regression tests. - Excludes buttons from label styles without increasing selector specificity.
- Deprecates the button’s
igxLabelinput and switches button groups to nativearia-label.
| File | Description |
|---|---|
| projects/igniteui-angular/directives/src/directives/button/README.md | Documents igxLabel deprecation and its replacement. |
| projects/igniteui-angular/directives/src/directives/button/button.directive.ts | Updates accessible-label handling and deprecates igxLabel. |
| projects/igniteui-angular/directives/src/directives/button/button.directive.spec.ts | Tests native labels and igxLabel updates and clearing. |
| projects/igniteui-angular/core/src/core/styles/components/label/_label-theme.scss | Excludes buttons from scoped label theme tokens. |
| projects/igniteui-angular/core/src/core/styles/components/label/_label-component.scss | Excludes buttons from label base styles. |
| projects/igniteui-angular/button-group/src/button-group/button-group-content.component.html | Binds button labels through native aria-label. |
| CHANGELOG.md | Records the deprecation and fixes for 22.2.8. |
Review effort: Balanced
Drop the snapshot and restore of the element's own aria-label. Clearing igxLabel now removes the attribute only if it still holds the value igxLabel wrote, so a newer native aria-label is kept and a hydrated server value is not mistaken for an authored one.
Member
|
This PR needs to be made against |
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.

Closes #18009
Cherry-pick of #18055 to 22.2.x.
Description
igxButtonno longer removes anaria-labelset on the button. The[attr.aria-label]host binding is gone. The button writesaria-labelwithRenderer2only whenigxLabelhas a value. WhenigxLabelis cleared, it removesaria-labelonly if the attribute still holds the valueigxLabelwrote, so a newer nativearia-labelis kept and a server-rendered value isn't mistaken for an authored one.The label styles (
[igxLabel]base rule, tokens and typography) now skip.igx-button. The selector is[igxLabel]:where(:not(.igx-button)), so specificity stays at (0,1,0).The button's
igxLabelinput is deprecated in favor of the nativearia-label. The button group now binds[attr.aria-label]instead of[igxLabel]; its rendered output is the same.Motivation / Context
Since 22.2.0 (#17155), the host binding wrote
nullwhenigxLabelwas unset, so Angular removed anyaria-labelthe template set, static,i18n-aria-labelor bound. Before that, the button setaria-labelonly whenigxLabelhad a value, as 21.2.x still does.The button's
igxLabelinput shares its name with the[igxLabel]selector ofIgxLabelDirective. A button written asigxLabel="...", as the button's JSDoc shows, matched the label CSS and took the label text color. #17988 made this visible, because the label styles are now kept whenigx-labelis excluded but an included component depends on it.Type of Change (check all that apply):
Component(s) / Area(s) Affected:
Button, Button Group, Theming (label)
How Has This Been Tested?
New specs in
button.directive.spec.tscover a staticaria-label, a boundaria-label, noaria-labelat all,igxLabelsetting and updatingaria-label, replacing a staticaria-labelwhile set, clearingigxLabelafter a newer nativearia-label, and clearing it after hydration. Three of them failed before the fix. The button, button group and input group specs andnpm run test:stylespass. In the full library run, the only failure is the hierarchical grid test "should skip nested child grids that have no data", which also fails on master.I compiled the light and dark Material, Indigo, Bootstrap and Fluent presets before and after. The only changes are the
[igxLabel]selectors (base, tokens, RTL and typography rules).I also ran an app that reported the issue against a local build, with SSR. The server HTML has the
aria-labelfromi18n-aria-label, and a button that usesigxLabelgets itsaria-labelon the server as well. After hydration both keep theiraria-labeland the button colors, and there are no hydration warnings.Test Configuration:
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)