fix(web): Close popover on Escape press (#6570)

* fix(web): Close popover on second Escape press when autocomplete options are closed

* [autofix.ci] apply automated fixes

* fix(web): use more accurate approach with isOpen

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Ilia Skliaruk
2026-01-06 19:44:50 +02:00
committed by GitHub
parent 31349b7bc8
commit 4055725106
3 changed files with 10 additions and 10 deletions

View File

@@ -562,7 +562,7 @@ function SingleAutocomplete<T extends AutocompleteItem>({
if (e.key === 'Escape') {
e.nativeEvent['preventDownshiftDefault'] = true;
if (!embedded) {
if (!embedded && isOpen) {
e.stopPropagation();
}

View File

@@ -928,18 +928,12 @@ describe('Transactions', () => {
let input = expectToBeEditingField(container, 'date', 0, true);
await userEvent.type(input, '[Tab]');
input = expectToBeEditingField(container, 'account', 0, true);
// The first escape closes the dropdown
await userEvent.type(input, '[Escape]');
await userEvent.type(input, '[Escape]');
expect(
container.querySelector('[data-testid="new-transaction"]'),
).toBeTruthy();
// TODO: Fix this
// Now it should close the new transaction form
// await userEvent.type(input, '[Escape]');
// expect(
// container.querySelector('[data-testid="new-transaction"]')
// ).toBeNull();
).toBeNull();
// The cancel button should also close the new transaction form
updateProps({ isAdding: true });

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [skliaruk]
---
Closes the popover on second Escape press once autocomplete options are closed.