diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 1e287f836c..16b49ab47a 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1328,9 +1328,11 @@ var ZoteroPane = new function() if (manual) { // Update most-recently-used list for New Item menu this.addItemTypeToNewItemTypeMRU(Zotero.ItemTypes.getName(typeID)); - - // Focus the title field - document.getElementById('zotero-editpane-item-box').focusFirstField(); + // Focus the title field if the itemPane is expanded + let itemPane = document.getElementById("zotero-item-pane"); + if (!itemPane.getAttribute("collapsed")) { + document.getElementById('zotero-item-pane-header').querySelector("editable-text").focus(); + } } return Zotero.Items.getAsync(itemID); diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js index 60e3cc3ec5..2a0500ad37 100644 --- a/test/tests/zoteroPaneTest.js +++ b/test/tests/zoteroPaneTest.js @@ -18,21 +18,19 @@ describe("ZoteroPane", function() { describe("#newItem", function () { it("should create an item and focus the title field", function* () { yield zp.newItem(Zotero.ItemTypes.getID('book'), {}, null, true); - var itemBox = doc.getElementById('zotero-editpane-item-box'); - var textboxes = itemBox.querySelectorAll('input, textarea'); - assert.lengthOf(textboxes, 1); - assert.equal(textboxes[0].getAttribute('fieldname'), 'title'); - textboxes[0].blur(); + let title = doc.getElementById('zotero-item-pane-header').querySelector("editable-text"); + assert.equal(doc.activeElement.getAttribute("aria-label"), title.getAttribute("aria-label")); + title.blur(); yield Zotero.Promise.delay(1); }) it("should save an entered value when New Item is used", function* () { var value = "Test"; var item = yield zp.newItem(Zotero.ItemTypes.getID('book'), {}, null, true); - var itemBox = doc.getElementById('zotero-editpane-item-box'); - var textbox = itemBox.querySelector('textarea'); - textbox.value = value; - yield itemBox.blurOpenField(); + let header = doc.getElementById('zotero-item-pane-header'); + let title = header.querySelector("editable-text"); + title.value = value; + yield header.save(); item = yield Zotero.Items.getAsync(item.id); assert.equal(item.getField('title'), value); })