From 4055725106bcb22be28e98c409069102b97110fe Mon Sep 17 00:00:00 2001 From: Ilia Skliaruk <58298423+skliaruk@users.noreply.github.com> Date: Tue, 6 Jan 2026 19:44:50 +0200 Subject: [PATCH] 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> --- .../src/components/autocomplete/Autocomplete.tsx | 2 +- .../transactions/TransactionsTable.test.tsx | 12 +++--------- upcoming-release-notes/6570.md | 6 ++++++ 3 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 upcoming-release-notes/6570.md diff --git a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx index b4f581a91f..bc00693bb0 100644 --- a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx +++ b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx @@ -562,7 +562,7 @@ function SingleAutocomplete({ if (e.key === 'Escape') { e.nativeEvent['preventDownshiftDefault'] = true; - if (!embedded) { + if (!embedded && isOpen) { e.stopPropagation(); } diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx index 0cafd8af4c..0625f34eaf 100644 --- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx +++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.tsx @@ -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 }); diff --git a/upcoming-release-notes/6570.md b/upcoming-release-notes/6570.md new file mode 100644 index 0000000000..ef497a9987 --- /dev/null +++ b/upcoming-release-notes/6570.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [skliaruk] +--- + +Closes the popover on second Escape press once autocomplete options are closed.