new item focus handling tweaks
- properly re-focus previously focused item type menu in itemBox - fix strange behavior of re-emerging item type menu popup caused by itemBox.focusFirstField - force the focus-ring to be around the itemType menu
This commit is contained in:
parent
b6d5a52417
commit
3338b4b285
2 changed files with 13 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue