diff --git a/chrome/content/zotero/elements/itemBox.js b/chrome/content/zotero/elements/itemBox.js index 1dca9703a6..af970fa306 100644 --- a/chrome/content/zotero/elements/itemBox.js +++ b/chrome/content/zotero/elements/itemBox.js @@ -458,6 +458,9 @@ if (activeArea) { this._selectField = activeArea.getAttribute("fieldname"); } + if (document.activeElement == this.itemTypeMenu) { + this._selectField = "item-type-menu"; + } this.refresh(); break; } @@ -488,6 +491,12 @@ this.addItemTypeMenu(); this.updateItemTypeMenuSelection(); this.itemTypeMenu.disabled = !this.showTypeMenu; + // Re-focus item type menu if it was focused before refresh + if (this._selectField == "item-type-menu") { + Services.focus.setFocus(this.itemTypeMenu, Services.focus.FLAG_SHOWRING); + this._selectField = null; + this._lastTabIndex = null; + } var fieldNames = []; // Manual field order @@ -2272,11 +2281,6 @@ }, this); } - focusFirstField() { - this._focusNextField(0); - } - - focusField(fieldName) { let field = this.querySelector(`[fieldname="${fieldName}"][ztabindex]`); if (!field) return false; diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 33a9de1941..ae219fbbbe 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1236,13 +1236,14 @@ var ZoteroPane = new function() itemBox.removeHandler('itemtypechange', handleTypeChange); itemBox.itemTypeMenu.firstChild.removeEventListener('popuphiding', removeTypeChangeHandler); // Focus the title field after menu closes - itemBox.focusFirstField(); + let title = document.querySelector("#zotero-item-pane-header").querySelector("editable-text"); + title.focus(); }; itemBox.addHandler('itemtypechange', handleTypeChange); itemBox.itemTypeMenu.firstChild.addEventListener('popuphiding', removeTypeChangeHandler); - menu.focus(); - document.getElementById('zotero-editpane-item-box').itemTypeMenu.menupopup.openPopup(menu, "before_start", 0, 0); + Services.focus.setFocus(menu, Services.focus.FLAG_SHOWRING); + itemBox.itemTypeMenu.menupopup.openPopup(menu, "before_start", 0, 0); }.bind(this)()); break; case 'newNote':