Skip to content

fix(aria/combobox): popup not closing when focus leaves it - #33697

Merged
ok7sai merged 2 commits into
angular:mainfrom
lazerg:fix/issue-33696-combobox-popup-focusout
Aug 26, 2026
Merged

fix(aria/combobox): popup not closing when focus leaves it#33697
ok7sai merged 2 commits into
angular:mainfrom
lazerg:fix/issue-33696-combobox-popup-focusout

Conversation

@lazerg

@lazerg lazerg commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Fixes that the popup was only closed from the trigger's focusout handler. When the popup renders outside the trigger and takes focus, the trigger never blurs again, so clicking away left the popup open. ComboboxPopupPattern.onFocusout now runs the same check once focus has left the popup as well.

Fixes #33696.

@lazerg
lazerg force-pushed the fix/issue-33696-combobox-popup-focusout branch from 15c903a to 60ae18f Compare August 18, 2026 18:50

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

Thanks for the contribution! Overall looks great with some comments.

/** Handles focus out events for the combobox. */
onFocusout() {
this.closePopupOnFocusout();
this.isFocused.set(false);

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.

Let's keep it consistent with ComboboxPopupPattern that sets the isFocused to false before calling the closePopupOnFocusout.

this.isFocused.set(false);
this.closePopupOnFocusout();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, done. closePopupOnFocusout reads isFocused inside a deferred setTimeout, so the order between the two calls never changed behavior, but matching ComboboxPopupPattern is worth it for consistency. Fixed in c0739c1.

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.

Let's also add tests to src/aria/combobox/combobox.spec.ts for testing directives in real use cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added two tests in src/aria/combobox/combobox.spec.ts under ComboboxWidget, using the real Combobox/ComboboxPopup/ComboboxWidget directives and a dialog popup with a focusable child. One confirms the popup closes when focus leaves it entirely without ever returning to the trigger, the other confirms it stays open when focus moves back to the trigger. Verified the first test fails on the pre-fix code and passes with it. Done in c0739c1.

@ok7sai ok7sai added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Aug 22, 2026
@ok7sai
ok7sai merged commit de579cc into angular:main Aug 26, 2026
35 checks passed
@ok7sai

ok7sai commented Aug 26, 2026

Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

ok7sai pushed a commit that referenced this pull request Aug 26, 2026
* fix(aria/combobox): popup not closing when focus leaves it

* fix(aria/combobox): set isFocused before closing popup on focusout

(cherry picked from commit de579cc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: aria/combobox 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(ngCombobox): outside-click closing is inconsistent/unreliable after a selection

2 participants