From 8278140492f16392eadac3c2062bb372020361cd Mon Sep 17 00:00:00 2001 From: abaevbog Date: Fri, 10 May 2024 03:23:20 -0400 Subject: [PATCH] Prevent empty item type menu from appearing after Cmd-Shift-N when info section is collapsed (#4105) If the info section is collapsed, do not try to focus and open the itemType menu as it can lead to an empty dropdown. Just focus the header title in that case --- chrome/content/zotero/elements/itemPaneSection.js | 4 ++++ chrome/content/zotero/zoteroPane.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/chrome/content/zotero/elements/itemPaneSection.js b/chrome/content/zotero/elements/itemPaneSection.js index a8e8d14847..2d06f75fc5 100644 --- a/chrome/content/zotero/elements/itemPaneSection.js +++ b/chrome/content/zotero/elements/itemPaneSection.js @@ -52,6 +52,10 @@ class ItemPaneSectionElementBase extends XULElementBase { this.setAttribute('tabType', tabType); } + get open() { + return this._section?.open || false; + } + connectedCallback() { super.connectedCallback(); if (!this.render && !this.asyncRender) { diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 03f78d4bce..06d9d52d97 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1305,6 +1305,11 @@ var ZoteroPane = new function() var type = mru ? mru.split(',')[0] : 'book'; await ZoteroPane.newItem(Zotero.ItemTypes.getID(type)); let itemBox = document.getElementById('zotero-editpane-item-box'); + // If the info pane is collapsed, focus the title in the header + if (!itemBox.open) { + document.querySelector("#zotero-item-pane-header editable-text").focus(); + return; + } var menu = itemBox.itemTypeMenu; // If the new item's type is changed immediately, update the MRU var handleTypeChange = function () {