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
This commit is contained in:
abaevbog 2024-05-10 03:23:20 -04:00 committed by GitHub
parent 85f58cc97d
commit 8278140492
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -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) {

View file

@ -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 () {