Skip to content

docs(aria/combobox): allow clear input with escape key#33282

Open
ok7sai wants to merge 1 commit into
angular:mainfrom
ok7sai:docs/autocomplete
Open

docs(aria/combobox): allow clear input with escape key#33282
ok7sai wants to merge 1 commit into
angular:mainfrom
ok7sai:docs/autocomplete

Conversation

@ok7sai
Copy link
Copy Markdown
Member

@ok7sai ok7sai commented May 20, 2026

No description provided.

@angular-robot angular-robot Bot added area: docs Related to the documentation area: aria/combobox labels May 20, 2026
@ok7sai ok7sai marked this pull request as ready for review May 20, 2026 07:51
@pullapprove pullapprove Bot requested review from adolgachev and crisbeto May 20, 2026 07:51
[(value)]="searchString"
[(expanded)]="popupExpanded"
(click)="popupExpanded.set(true)"
(keydown.escape)="!popupExpanded() && !$event.defaultPrevented && searchString.set('')"
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.

Do we need the defaultPrevented check? I'm not sure we're preventing it anywhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

https://github.com/angular/components/blob/main/src/aria/private/combobox/combobox.ts#L140 the combobox handles the escape key and prevents default, without the defaultPrevented the input box will be cleared even when the popup is opened (the clear behavior should only happen when the popup is closed and escape hit is hit)... popupExpanded() returns false immediately once the escape key is hit, so we can't rely on that value.

Maybe the clear behavior needs to be baked into the combobox pattern... Let me take a further look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: aria/combobox area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants