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
This commit is contained in:
abaevbog 2023-11-21 07:42:33 -05:00 committed by GitHub
parent 9d710ea135
commit 436b19d64c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();
}
}
}
}