refactor(button): Migrate to signal backed state management#17155
refactor(button): Migrate to signal backed state management#17155rkaraivanov wants to merge 3 commits intomasterfrom
Conversation
- Migrated the button directives to use signals for state management. - Use `host` metadata for simplified DOM bindings. - Introduced a new `FocusRingDirective` to handle focus ring visibility on buttons.
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. |
| public get nativeElement() { | ||
| return this.element.nativeElement; | ||
| public ngAfterViewInit(): void { | ||
| // FUOC workaround - ensures that the transition is only applied after the initial render |
There was a problem hiding this comment.
The FOUC/transition suppression logic now flips _hasRendered to true synchronously in ngAfterViewInit(). Previously this was deferred to the next animation frame in the browser to ensure transitions are only enabled after the first paint (see the removed animationFrameScheduler.schedule(...) logic). This change can reintroduce the flicker the workaround was meant to address; consider restoring the “next frame” deferral (browser-only) rather than enabling transitions immediately in ngAfterViewInit().
| // FUOC workaround - ensures that the transition is only applied after the initial render | |
| // FUOC workaround - ensures that the transition is only applied after the initial render | |
| if (typeof requestAnimationFrame === 'function') { | |
| requestAnimationFrame(() => this._hasRendered.set(true)); | |
| return; | |
| } |
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)