Skip to content

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

Open
rkaraivanov wants to merge 3 commits into
masterfrom
rkaraivanov/buttons-to-signals
Open

rkaraivanov wants to merge 3 commits into
masterfrom
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

@rkaraivanov
rkaraivanov requested a review from simeonoff April 3, 2026 08:00
@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

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.

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.

Comment thread projects/igniteui-angular/directives/src/directives/button/button-base.ts Outdated
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

@simeonoff simeonoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This refactoring reintroduces an issue previously closed by https://github.com/IgniteUI/igniteui-angular/pull/16858/changes.

Here's the issue in question: #16817

@github-actions

Copy link
Copy Markdown

There has been no recent activity and this PR has been marked inactive.

@github-actions github-actions Bot added the status: inactive Used to stale issues and pull requests label Aug 23, 2026
@simeonoff simeonoff removed the status: inactive Used to stale issues and pull requests label Aug 26, 2026
@simeonoff
simeonoff requested a lite review from Copilot September 10, 2026 08:42

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

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

Comment thread projects/igniteui-angular/directives/src/directives/button/button.directive.ts Outdated
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.
@rkaraivanov
rkaraivanov force-pushed the rkaraivanov/buttons-to-signals branch from 922ba50 to 2de7390 Compare September 16, 2026 12:12
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.

3 participants