You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(button): keep aria-label set outside igxLabel - 22.3.x - #18056
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
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Clearing igxLabel can restore stale accessible labels after native aria-label updates or SSR hydration, leaving buttons with incorrect accessible names.
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.
In the combined-binding fixture, change ariaLabel from 'Save' to 'Close', run change detection, then clear label: this removes the newer native label because its text matches _label. The unchanged native binding will not write it back, leaving the button without its authored accessible name. Track intervening native writes independently of text equality, and add this equal-value case to the regression test.
The equal-value case is a known limit of the ownership check and is intentional. Telling a native write apart from igxLabel's own value when the text is identical would need a MutationObserver on every button, because Angular writes [attr.aria-label] straight to the element. That isn't worth it for an input deprecated in this PR. The igxLabel JSDoc documents that while it has a value it replaces any other aria-label, and the migration path is to use aria-label alone.
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
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.3.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. #17987 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)