Focus pdf-reader on tab selection if not focused contextPane note editor

This commit is contained in:
Martynas Bagdonas 2021-03-23 17:57:06 +02:00
parent f690c666d4
commit 3d204f75e9
3 changed files with 15 additions and 0 deletions

View file

@ -341,6 +341,7 @@
<content>
<xul:vbox xbl:inherits="flex" style="display: flex;flex-direction: column;flex-grow: 1;">
<!-- Notice: Update query selector for `iframe[anonid="editor-view"]` in contextPane.js if updating this -->
<xul:iframe tooltip="editor-tooltip" anonid="editor-view" flex="1" overflow="auto" style="width: 100%;margin-right: 5px;border: 0;width: 100%;margin-right: 5px;border: 0;flex-grow: 1;"
frameBorder="0" src="resource://zotero/note-editor/editor.html" type="content"/>
<xul:hbox id="links-container" hidden="true">

View file

@ -170,6 +170,12 @@ var ZoteroContextPane = new function () {
(async () => {
await reader._initPromise;
_tabCover.hidden = true;
// Focus reader pages view if context pane note editor is not selected
if (Zotero_Tabs.selectedID == reader.tabID
&& (!document.activeElement
|| !document.activeElement.closest('.context-node iframe[anonid="editor-view"]'))) {
reader.focus();
}
})();
var attachment = Zotero.Items.get(reader.itemID);

View file

@ -40,6 +40,14 @@ class ReaderInstance {
});
}
focus() {
try {
this._iframeWindow.document.querySelector('#viewerContainer').focus();
}
catch (e) {
}
}
async open({ itemID, state, location }) {
let item = await Zotero.Items.getAsync(itemID);
if (!item) {