Skip to content

A local-first personal finance app

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

Ilia Skliaruk4055725106bc
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<T extends AutocompleteItem>({
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.