diff --git a/chrome/content/zotero/integration/citationDialog.xhtml b/chrome/content/zotero/integration/citationDialog.xhtml index 1900a29f51..58fee6d474 100644 --- a/chrome/content/zotero/integration/citationDialog.xhtml +++ b/chrome/content/zotero/integration/citationDialog.xhtml @@ -122,7 +122,7 @@
- +
@@ -138,7 +138,7 @@ diff --git a/chrome/content/zotero/integration/citationDialog/keyboardHandler.mjs b/chrome/content/zotero/integration/citationDialog/keyboardHandler.mjs index 6f37569880..c14f2ca8b7 100644 --- a/chrome/content/zotero/integration/citationDialog/keyboardHandler.mjs +++ b/chrome/content/zotero/integration/citationDialog/keyboardHandler.mjs @@ -86,12 +86,19 @@ export class CitationDialogKeyboardHandler { _handleTopLevelKeydown(event) { let handled = false; let tgt = event.target; - let isKeyboardClickable = tgt.classList.contains("keyboard-clickable") || tgt.tagName.includes("button"); - // Space/Enter will click on a button or keyboard-clickable components + // Space/Enter will click on keyboard-clickable components. + // On macOS, focused buttons are only clickable with Space (not Enter), + // and on Windows they are clickable with both. + let isKeyboardClickable = tgt.classList.contains("keyboard-clickable") || (Zotero.isWin && tgt.localName == "button"); if (["Enter", " "].includes(event.key) && isKeyboardClickable) { tgt.click(); handled = true; } + // Unhandled Enter in a panel will close it + else if (event.key == "Enter" && tgt.closest("panel")) { + handled = true; + tgt.closest("panel").hidePopup(); + } // Unhandled Enter will accept the existing dialog's state else if (event.key == "Enter" && !tgt.closest("panel")) { handled = true; diff --git a/chrome/content/zotero/integration/citationDialog/popupHandler.mjs b/chrome/content/zotero/integration/citationDialog/popupHandler.mjs index fd065409f1..dbf43f279e 100644 --- a/chrome/content/zotero/integration/citationDialog/popupHandler.mjs +++ b/chrome/content/zotero/integration/citationDialog/popupHandler.mjs @@ -84,8 +84,6 @@ export class CitationDialogPopupsHandler { if (this._getNode("#itemDetails").state !== "open") return; this.captureItemDetailsKeyDown(event); }, true); - // Handle remaining keypress events with a usual bubbling listener - this._getNode("#itemDetails").addEventListener("keypress", this.handleItemDetailsKeypress.bind(this)); } openItemDetails(dialogReferenceID, item, citationItem, itemDescription) { @@ -182,13 +180,6 @@ export class CitationDialogPopupsHandler { } } - handleItemDetailsKeypress(event) { - // Enter on a an input will save changes and hide the popup - if (event.key == "Enter" && ["input"].includes(event.target.tagName) && !event.target.getAttribute("type")) { - this._getNode("#itemDetails").hidePopup(); - } - } - // Update item details and notify citation dialog about changes handleItemDetailsChange() { this.citationItem.label = this._getNode("#locator").value ? this._getNode("#label").value : null;