refactor(button): Migrate to signal backed state management - #17155
rkaraivanov wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors Ignite UI button directives to use Angular signals and host metadata bindings, and introduces a focus-ring directive to track keyboard focus styling.
Changes:
- Added
IgxFocusRingDirectiveand integrated it viahostDirectivesfor focus-ring state. - Migrated
IgxButtonDirective/IgxIconButtonDirectiveto signal-backed state andhostbindings (replacing@HostBinding/@HostListenerpatterns). - Updated
IgxButtonGroupComponentand its spec to useselectedproperty assignment instead ofselect()/deselect().
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/igniteui-angular/directives/src/directives/focus-ring/focus-ring.directive.ts | New directive for tracking keyboard-focus modality. |
| projects/igniteui-angular/directives/src/directives/button/icon-button.directive.ts | Refactors icon button type state to a signal and host class bindings. |
| projects/igniteui-angular/directives/src/directives/button/button.directive.ts | Refactors button type/label/selected state to signals and host bindings. |
| projects/igniteui-angular/directives/src/directives/button/button-base.ts | Moves base button host bindings to host, adds focus-ring host directive integration, and updates transition suppression logic. |
| projects/igniteui-angular/button-group/src/button-group/button-group.component.ts | Updates selection/deselection logic to use selected property. |
| projects/igniteui-angular/button-group/src/button-group/button-group.component.spec.ts | Aligns tests with the new selection API usage. |
simeonoff
left a comment
There was a problem hiding this comment.
This refactoring reintroduces an issue previously closed by https://github.com/IgniteUI/igniteui-angular/pull/16858/changes.
Here's the issue in question: #16817
|
There has been no recent activity and this PR has been marked inactive. |
There was a problem hiding this comment.
🟡 Changes recommended
It introduces API/behavioral risk (e.g., hard-coding role in the base directive) and has at least one maintainability regression to address (duplicate deselection updates), plus the new focus-ring behavior lacks unit coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 5
- Review effort level: Lite
Replace the @HostBinding/@HostListener members on the button, icon-button and their base with host metadata backed by signals. Host bindings now read _type, _disabled, _selected and _label directly, so the Renderer2 writes for data-selected and aria-label go away. Keyboard focus tracking moves into a new IgxFocusRingDirective, attached as a host directive. It exposes a readonly hasKeyboardFocus signal that the base binds to igx-button--focused. Transitions stay off until the first paint. The base flips _hasRendered through runAfterRenderOnce and each directive binds its own --ready modifier, which the SCSS already gates on. This replaces the readyClass override and the classList.add call (#14759, #16817). Button group sets `selected` and updates its bookkeeping directly since the directive no longer exposes select()/deselect(), and no longer runs updateDeselected twice per button in single mode. Public API removed: element, role, focused, select(), deselect(). The static host role still yields to a role set in the template.
922ba50 to
2de7390
Compare
hostmetadata for simplified DOM bindings.FocusRingDirectiveto handle focus ring visibility on buttons.Additional information (check all that apply):
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)