Skip to content

Commit 27fe15d

Browse files
committed
fix(aria/combobox): focus out selection bug
* Navigating away from an auto-select or highlight combobox input should only trigger selection if the combobox popup is expanded.
1 parent 481da1d commit 27fe15d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/aria/private/combobox/combobox.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,13 @@ describe('Combobox with Listbox Pattern', () => {
488488
combobox.onFocusOut(new FocusEvent('focusout'));
489489
expect(inputEl.value).toBe('Apple');
490490
});
491+
492+
it('should not commit an option on focusout if the popup is closed', () => {
493+
type('A');
494+
combobox.onKeydown(escape());
495+
combobox.onFocusOut(new FocusEvent('focusout'));
496+
expect(inputEl.value).toBe('A');
497+
});
491498
});
492499

493500
describe('when filterMode is "highlight"', () => {

src/aria/private/combobox/combobox.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ export class ComboboxPattern<T extends ListItem<V>, V> {
388388
) {
389389
this.isFocused.set(false);
390390

391+
if (!this.expanded()) {
392+
return;
393+
}
394+
391395
if (this.readonly()) {
392396
this.close();
393397
return;

0 commit comments

Comments
 (0)