From 79e56b9bbb942977330cc75c3043fb48f346db89 Mon Sep 17 00:00:00 2001
From: Jed Fox <git@jedfox.com>
Date: Thu, 16 Feb 2023 13:03:16 -0500
Subject: [PATCH] Improve handling of the undo/redo shortcuts (#659)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Prevent Cmd+Z/Cmd+Shift+Z from propagating to the browser

* Allow browser to handle undo/redo shortcuts in input fields

* Don’t change a transaction’s note from null to ''
---
 packages/desktop-client/src/browser-preload.browser.js    | 8 ++++++++
 .../src/components/accounts/TransactionsTable.js          | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/packages/desktop-client/src/browser-preload.browser.js b/packages/desktop-client/src/browser-preload.browser.js
index b8b26bee6..3f183e4ee 100644
--- a/packages/desktop-client/src/browser-preload.browser.js
+++ b/packages/desktop-client/src/browser-preload.browser.js
@@ -168,6 +168,14 @@ document.addEventListener('keydown', e => {
     }
     // Cmd/Ctrl+z
     else if (e.keyCode === 90) {
+      if (
+        e.target.tagName === 'INPUT' ||
+        e.target.tagName === 'TEXTAREA' ||
+        e.target.isContentEditable
+      ) {
+        return;
+      }
+      e.preventDefault();
       if (e.shiftKey) {
         // Redo
         window.__actionsForMenu.redo();
diff --git a/packages/desktop-client/src/components/accounts/TransactionsTable.js b/packages/desktop-client/src/components/accounts/TransactionsTable.js
index 0d5a3d50d..54d15ac2c 100644
--- a/packages/desktop-client/src/components/accounts/TransactionsTable.js
+++ b/packages/desktop-client/src/components/accounts/TransactionsTable.js
@@ -557,6 +557,11 @@ export const Transaction = React.memo(function Transaction(props) {
     if (transaction[name] !== value) {
       let newTransaction = { ...transaction, [name]: value };
 
+      // Don't change the note to an empty string if it's null (since they are both rendered the same)
+      if (name === 'note' && value === '' && transaction.note == null) {
+        return;
+      }
+
       if (
         name === 'account' &&
         value &&
-- 
GitLab