Skip to content

Conversation

crisbeto
Copy link
Member

Resolves a couple of issues with how focus is managed in the chips. Includes:

fix(material/chips): chip grid not re-focusing first item

There was some logic that assumed that if a chip is the active item in the key manager, it must have focus. That's incorrect since the active item isn't reset on blur. This prevented the chip grid from re-focusing the first chip when the user tabs into it a second time.

These changes add a focus call whenever the grid receives focus.

Fixes #29785.

fix(material/chips): focus escape not working consistently

Fixes that the chip grid was using change detection to allow focus to escape on tab presses. That's unreliable, because change detection might not be executed immediately. These changes fix the issue by changing the DOM node directly.

There was some logic that assumed that if a chip is the active item in the key manager, it must have focus. That's incorrect since the active item isn't reset on blur. This prevented the chip grid from re-focusing the first chip when the user tabs into it a second time.

These changes add a `focus` call whenever the grid receives focus.

Fixes angular#29785.
Fixes that the chip grid was using change detection to allow focus to escape on tab presses. That's unreliable, because change detection might not be executed immediately. These changes fix the issue by changing the DOM node directly.
@crisbeto crisbeto added Accessibility This issue is related to accessibility (a11y) target: patch This PR is targeted for the next patch release labels Sep 26, 2024
@crisbeto crisbeto requested a review from a team as a code owner September 26, 2024 07:14
@crisbeto crisbeto requested review from amysorto and andrewseguin and removed request for a team September 26, 2024 07:14
@crisbeto crisbeto added the merge: preserve commits When the PR is merged, a rebase and merge should be performed label Sep 26, 2024
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Sep 30, 2024
@crisbeto crisbeto merged commit 8e17112 into angular:main Sep 30, 2024
27 of 29 checks passed
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker merge: preserve commits When the PR is merged, a rebase and merge should be performed target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(MatChipGrid): The focus indicator is not displayed for the chip grid when navigating through a MatChipGrid component the second time

2 participants