Skip to content

feat(button): add focusVisible to show the focused state - #18030

Open
onlyexeption wants to merge 3 commits into
ibarakov/fix-17992from
ibarakov/fix-18023
Open

onlyexeption wants to merge 3 commits into
ibarakov/fix-17992from
ibarakov/fix-18023

Conversation

@onlyexeption

Copy link
Copy Markdown
Contributor

Closes #18023

Description

  • IgxComboAddItemComponent now renders the default "Add item" button from its own template (combo-add-item.component.html). The combos pass it [template] (the custom igxComboAddItem template) and [label] instead of the customTemplate flag.
  • The combo and simple combo templates no longer duplicate the button and no longer set igx-button--focused from outside.
  • New focusVisible input on igxButton / igxIconButton. It shows the focused state while focus is on another element (e.g. a list using aria-activedescendant), combined with the button's own keyboard focus. The add item binds [focusVisible]="active", so the || undefined workaround is gone.

Motivation / Context

Follow-up from the #18019 review: the default button was copy-pasted in both combos, and its focus class was set from outside with a fragile || undefined binding. Builds on #18019, so its commits show here until it merges.

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:

Combo, Simple Combo, Button (igxButton, igxIconButton)

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

New specs: focusVisible on igxButton (set/unset, own keyboard focus, pointerdown) and igxIconButton, plus switching addItemTemplate at runtime. All existing add item specs pass unchanged (513 tests across combo, simple combo, drop-down, button and button-group). A temporary before/after comparison found the add item's DOM, classes and computed styles identical in every focus state, and Enter/click, ripple and custom-template behavior unchanged.

Test Configuration:

  • Angular version: 22.2.3
  • Browser(s): Chromium (Vitest browser mode)
  • OS: Windows 11

Screenshots / Recordings

None, no visual change.

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

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.

🟢 Approval recommended

No active review issues block approval of the button focus-state and shared Combo add-item changes.

No open issues 🎉

What changed in this PR

Adds focusVisible to igxButton and igxIconButton and centralizes the Combo “Add item” button, addressing #18023 without external focus-class bindings.

Changes:

  • Combines the new focusVisible input with each button’s own keyboard-focus state.
  • Moves default and custom add-item rendering into IgxComboAddItemComponent, shared by Combo and Simple Combo.
  • Adds focus-state and runtime template-switching tests, plus API documentation and release notes.
File Description
projects/​igniteui-angular/​simple-combo/​src/​simple-combo/​simple-combo.component.ts Removes button and ripple imports now owned by the add-item component.
projects/​igniteui-angular/​simple-combo/​src/​simple-combo/​simple-combo.component.html Passes the template and label instead of duplicating button markup.
projects/​igniteui-angular/​directives/​src/​directives/​button/​README.md Documents focusVisible for buttons and icon buttons.
projects/​igniteui-angular/​directives/​src/​directives/​button/​icon-button.directive.spec.ts Tests enabling and clearing the icon button’s focus state.
projects/​igniteui-angular/​directives/​src/​directives/​button/​button.directive.spec.ts Tests explicit focus state, keyboard focus, and pointer interaction.
projects/​igniteui-angular/​directives/​src/​directives/​button/​button-base.ts Adds focusVisible and combines it with keyboard focus.
projects/​igniteui-angular/​combo/​src/​combo/​combo.component.ts Removes button and ripple imports now owned by the add-item component.
projects/​igniteui-angular/​combo/​src/​combo/​combo.component.spec.ts Tests switching between default and custom add-item templates at runtime.
projects/​igniteui-angular/​combo/​src/​combo/​combo.component.html Delegates add-item rendering through template and label inputs.
projects/​igniteui-angular/​combo/​src/​combo/​combo-add-item.component.ts Owns rendering inputs and preserves custom-template focus styling.
projects/​igniteui-angular/​combo/​src/​combo/​combo-add-item.component.html Provides shared add-item markup using focusVisible.
CHANGELOG.md Announces the new button input.

Review effort: Balanced

@IMinchev64 IMinchev64 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.

Heads up: since this targets ibarakov/fix-17992 instead of master, the CI checks don't run here, so this isn't visible on the PR. npm run build:lib fails:

combo.component.html:122:42 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.

resourceStrings.igx_combo_addCustomValues_placeholder is string | undefined (all resource string keys are optional), but the new label input is typed string. Same thing in simple-combo.component.html:118. Typing it as label: string | undefined = '' (or adding ?? '' in both templates) should fix it.

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.

🟢 Approval recommended

No active review issues were identified in the button focus API and centralized Combo add-item rendering changes.

No open issues 🎉

Review effort: Balanced

@kdinev
kdinev added this pull request to stack #18033 November 23, 2026 12:12
@kdinev

kdinev commented Nov 23, 2026

Copy link
Copy Markdown
Member

@IMinchev64 I changed this to a stacked PR. I think that was the intention.

IMinchev64
IMinchev64 previously approved these changes Nov 23, 2026

This branch has not been deployed

No deployments
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.

[Refactor] Combo: render the default "Add item" button inside IgxComboAddItemComponent

4 participants