Skip to content

fix(button): keep aria-label set outside igxLabel - 22.2.x - #18057

Closed
simeonoff wants to merge 2 commits into
22.2.xfrom
simeonoff/fix-18009-button-aria-label-22.2.x
Closed

simeonoff wants to merge 2 commits into
22.2.xfrom
simeonoff/fix-18009-button-aria-label-22.2.x

Conversation

@simeonoff

@simeonoff simeonoff commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Closes #18009

Cherry-pick of #18055 to 22.2.x.

Description

igxButton no longer removes an aria-label set on the button. The [attr.aria-label] host binding is gone. The button writes aria-label with Renderer2 only when igxLabel has a value. When igxLabel is cleared, it removes aria-label only if the attribute still holds the value igxLabel wrote, so a newer native aria-label is 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 igxLabel input is deprecated in favor of the native aria-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 null when igxLabel was unset, so Angular removed any aria-label the template set, static, i18n-aria-label or bound. Before that, the button set aria-label only when igxLabel had a value, as 21.2.x still does.

The button's igxLabel input shares its name with the [igxLabel] selector of IgxLabelDirective. A button written as igxLabel="...", 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 when igx-label is excluded but an included component depends on it.

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

Button, Button Group, Theming (label)

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

New specs in button.directive.spec.ts cover a static aria-label, a bound aria-label, no aria-label at all, igxLabel setting and updating aria-label, replacing a static aria-label while set, clearing igxLabel after a newer native aria-label, and clearing it after hydration. Three of them failed before the fix. The button, button group and input group specs and npm run test:styles pass. 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-label from i18n-aria-label, and a button that uses igxLabel gets its aria-label on the server as well. After hydration both keep their aria-label and the button colors, and there are no hydration warnings.

Test Configuration:

  • Angular version: 22.2
  • Browser(s): Chrome
  • OS: macOS

Checklist:

  • All relevant labels have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

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
@simeonoff simeonoff added 🐛 bug Any issue that describes a bug button-theme button labels Nov 25, 2026
Copilot AI balanced review requested due to automatic review settings November 25, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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-label host binding with targeted attribute updates and adds regression tests.
  • Excludes buttons from label styles without increasing selector specificity.
  • Deprecates the button’s igxLabel input and switches button groups to native aria-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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the button accessibility and styling backport.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@kdinev

kdinev commented Nov 25, 2026

Copy link
Copy Markdown
Member

This PR needs to be made against 21.2.x instead

@simeonoff simeonoff closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants