Skip to content

fix(button): keep aria-label set outside igxLabel - master - #18055

Merged
kdinev merged 3 commits into
masterfrom
simeonoff/fix-18009-button-aria-label
Nov 25, 2026
Merged

kdinev merged 3 commits into
masterfrom
simeonoff/fix-18009-button-aria-label

Conversation

@simeonoff

@simeonoff simeonoff commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Closes #18009

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. #17987 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

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 a newer native aria-label or retain a stale server-rendered label after hydration, leaving buttons with incorrect or missing accessible names.

2 open issues
What changed in this PR

Addresses #18009 by preserving button accessibility labels and preventing label-theme styles from changing button colors. It also deprecates the button’s igxLabel input in favor of native aria-label.

Changes:

  • Replaces the button’s aria-label host binding with conditional attribute updates and restoration.
  • Excludes .igx-button from label styles without increasing selector specificity.
  • Updates button-group bindings, regression tests, API documentation, and release notes.
File Description
projects/​igniteui-angular/​directives/​src/​directives/​button/​README.md Documents igxLabel deprecation.
projects/​igniteui-angular/​directives/​src/​directives/​button/​button.directive.ts Changes accessible-label updates and fallback restoration.
projects/​igniteui-angular/​directives/​src/​directives/​button/​button.directive.spec.ts Adds label preservation, update, and clearing tests.
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 structural 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 button fixes.

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

There are no active review issues blocking approval.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@kdinev kdinev added the ✅ status: verified Applies to PRs that have passed manual verification label Nov 25, 2026
@kdinev
kdinev enabled auto-merge (squash) November 25, 2026 14:11
@kdinev
kdinev merged commit d27c0da into master Nov 25, 2026
8 of 9 checks passed
@kdinev
kdinev deleted the simeonoff/fix-18009-button-aria-label branch November 25, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Any issue that describes a bug button button-theme label version: 22.4.x ✅ status: verified Applies to PRs that have passed manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[igxButton]: Font color differs on buttons depending on whether igxLabel is applied or not

3 participants