fix to "show in library" not focusing the itemTree (#3836)

- handle additional focusElementID options value in Zotero_Tabs.select to
focus a node with the specified ID, instead of what was recorded
as last focused element
- use that parameter in ZoteroPane.selectItems to make sure that
itemTree is focused after the tab is switched to zotero-pane
- removed redundant calls to Zotero_Tabs.select('zotero-pane') after
Zotero_Pane.selectItems
This commit is contained in:
abaevbog 2024-03-12 18:57:48 -04:00 committed by GitHub
parent e7f899c09d
commit 8e5732cf9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4 additions and 4 deletions

View file

@ -410,6 +410,9 @@ var Zotero_Tabs = new function () {
// Move focus to the last focused element of zoteroPane if any or itemTree otherwise // Move focus to the last focused element of zoteroPane if any or itemTree otherwise
let focusZoteroPane = () => { let focusZoteroPane = () => {
if (tab.id !== 'zotero-pane') return; if (tab.id !== 'zotero-pane') return;
if (options.focusElementID) {
tab.lastFocusedElement = document.getElementById(options.focusElementID);
}
// Small delay to make sure the focus does not remain on the actual // Small delay to make sure the focus does not remain on the actual
// tab after mouse click // tab after mouse click
setTimeout(() => { setTimeout(() => {
@ -658,7 +661,6 @@ var Zotero_Tabs = new function () {
itemID = item.parentItemID; itemID = item.parentItemID;
} }
ZoteroPane_Local.selectItem(itemID); ZoteroPane_Local.selectItem(itemID);
this.select('zotero-pane');
} }
}); });
popup.appendChild(menuitem); popup.appendChild(menuitem);

View file

@ -315,7 +315,6 @@ class EditorInstance {
let win = Zotero.getMainWindow(); let win = Zotero.getMainWindow();
if (win) { if (win) {
win.ZoteroPane.selectItems(ids); win.ZoteroPane.selectItems(ids);
win.Zotero_Tabs.select('zotero-pane');
win.focus(); win.focus();
} }
} }

View file

@ -730,7 +730,6 @@ class ReaderInstance {
let item = Zotero.Items.get(this._item.id); let item = Zotero.Items.get(this._item.id);
let id = item.parentID || item.id; let id = item.parentID || item.id;
win.ZoteroPane.selectItems([id]); win.ZoteroPane.selectItems([id]);
win.Zotero_Tabs.select('zotero-pane');
win.focus(); win.focus();
} }
} }

View file

@ -3110,7 +3110,7 @@ var ZoteroPane = new function()
document.getElementById(ZoteroPane.itemsView.id).focus(); document.getElementById(ZoteroPane.itemsView.id).focus();
} }
Zotero_Tabs.select('zotero-pane'); Zotero_Tabs.select('zotero-pane', false, { focusElementID: ZoteroPane.itemsView.id });
}; };