minor focus tweaks
- after an item is added via "Add item by identifier" panel, end focus to that item in itemTree. - restored default behavior when the focus remains visible around an element when all menupopups open, except for the item type menu in itemBox. - opening item type menu will still hide the focus-ring
This commit is contained in:
parent
ed8e3f142b
commit
620b35ab78
2 changed files with 7 additions and 3 deletions
|
@ -144,7 +144,10 @@ var Zotero_Lookup = new function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (newItems.length) {
|
if (newItems.length) {
|
||||||
|
// Send the focus to the item tree after the popup closes
|
||||||
|
ZoteroPane.lastFocusedElement = null;
|
||||||
document.getElementById("zotero-lookup-panel").hidePopup();
|
document.getElementById("zotero-lookup-panel").hidePopup();
|
||||||
|
document.getElementById("item-tree-main-default").focus();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -436,9 +436,10 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFocusHandlers() {
|
function addFocusHandlers() {
|
||||||
// When a menupopup shows, hide the focus ring around the currently focused element
|
// When the item type menupopup from itemBoxshows,
|
||||||
|
// hide the focus ring around the currently focused element
|
||||||
document.addEventListener("popupshowing", (e) => {
|
document.addEventListener("popupshowing", (e) => {
|
||||||
if (e.target.tagName == "menupopup") {
|
if (e.target.tagName == "menupopup" && e.target.parentNode.id == "item-type-menu") {
|
||||||
document.activeElement.style.setProperty('--width-focus-border', '0');
|
document.activeElement.style.setProperty('--width-focus-border', '0');
|
||||||
document.activeElement.classList.add("hidden-focus");
|
document.activeElement.classList.add("hidden-focus");
|
||||||
}
|
}
|
||||||
|
@ -447,7 +448,7 @@ var ZoteroPane = new function()
|
||||||
// When a panel popup hides, refocus the previous element
|
// When a panel popup hides, refocus the previous element
|
||||||
// When a menupopup hides, stop hiding the focus-ring
|
// When a menupopup hides, stop hiding the focus-ring
|
||||||
document.addEventListener("popuphiding", (e) => {
|
document.addEventListener("popuphiding", (e) => {
|
||||||
if (e.target.tagName == "panel"
|
if (ZoteroPane.lastFocusedElement && e.target.tagName == "panel"
|
||||||
&& document.activeElement && e.target.contains(document.activeElement)) {
|
&& document.activeElement && e.target.contains(document.activeElement)) {
|
||||||
ZoteroPane.lastFocusedElement.focus();
|
ZoteroPane.lastFocusedElement.focus();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue