Skip to content

refactor(button): Migrate to signal backed state management#17155

Open
rkaraivanov wants to merge 3 commits intomasterfrom
rkaraivanov/buttons-to-signals
Open

refactor(button): Migrate to signal backed state management#17155
rkaraivanov wants to merge 3 commits intomasterfrom
rkaraivanov/buttons-to-signals

Conversation

@rkaraivanov
Copy link
Copy Markdown
Member

  • 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.

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags 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

- 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.
@rkaraivanov rkaraivanov marked this pull request as ready for review April 27, 2026 06:45
Copilot AI review requested due to automatic review settings April 27, 2026 06:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 IgxFocusRingDirective and integrated it via hostDirectives for focus-ring state.
  • Migrated IgxButtonDirective / IgxIconButtonDirective to signal-backed state and host bindings (replacing @HostBinding/@HostListener patterns).
  • Updated IgxButtonGroupComponent and its spec to use selected property assignment instead of select()/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
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

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().

Suggested change
// 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;
}

Copilot uses AI. Check for mistakes.
Comment thread projects/igniteui-angular/directives/src/directives/button/button.directive.ts Outdated
Comment thread projects/igniteui-angular/directives/src/directives/button/button-base.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants