From 436b19d64cb942644ea80705b5247dc52e6ebeb7 Mon Sep 17 00:00:00 2001 From: abaevbog Date: Tue, 21 Nov 2023 07:42:33 -0500 Subject: [PATCH] Fix inconsistent ESC behavior on text edit when reader is opened (#3417) This is needed to let itemBox, tagBox, etc. to handle ESC events to revent any edits made to textfields. Only applied if the currently focused element is input or textarea. Fixes: #3246 --- chrome/content/zotero/zoteroPane.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 5647bd0b7a..b52f66a70e 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -843,8 +843,12 @@ var ZoteroPane = new function() let reader = Zotero.Reader.getByTabID(Zotero_Tabs.selectedID); if (reader) { reader.focus(); - event.preventDefault(); - event.stopPropagation(); + // Keep propagating if current focus is on input or textarea + // The Escape event needs to be handled by itemBox, tagBox, etc. to undo edits. + if (!["input", "textarea"].includes(document.activeElement.tagName)) { + event.preventDefault(); + event.stopPropagation(); + } } } }