This commit is contained in:
abaevbog 2026-08-25 07:10:58 +08:00 committed by GitHub
commit dbcfff5dab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 15 deletions

View file

@ -745,21 +745,25 @@
});
firstBtn.dispatchEvent(clickEvent);
}
setTimeout(() => {
// If notes are visible, tab into them
if (this._contextNotesPaneVisible) {
Services.focus.moveFocus(window, this.contextNotesPane, Services.focus.MOVEFOCUS_FORWARD, 0);
}
// Tab into the pinned section if it exists
else if (this.pinnedPane) {
Services.focus.moveFocus(window, this.container.getEnabledPane(this.pinnedPane),
Services.focus.MOVEFOCUS_FORWARD, 0);
}
// Otherwise, focus the top-level scrollable itemPane
else {
this._container.querySelector(".zotero-view-item").focus();
}
});
// Otherwise, just click on the focused button
else if (event.target.classList.contains("btn")) {
event.preventDefault();
event.target.click();
}
// If notes are visible, tab into them
if (this._contextNotesPaneVisible) {
Services.focus.moveFocus(window, this.contextNotesPane, Services.focus.MOVEFOCUS_FORWARD, 0);
}
// Tab into the pinned section if it exists
else if (this.pinnedPane) {
Services.focus.moveFocus(window, this.container.getEnabledPane(this.pinnedPane),
Services.focus.MOVEFOCUS_FORWARD, 0);
}
// Otherwise, focus the top-level scrollable itemPane
else {
this._container.querySelector(".zotero-view-item").focus();
}
}
};

View file

@ -779,6 +779,25 @@ class ReaderInstance {
async setContextPaneOpen(open) {
await this._initPromise;
// There are two toggle-pane buttons: in the reader and in the sidenav. Closing/opening
// the context pane may display one and hide the other. If a focused toggle-pane btn is being hidden,
// try to focus the other toggle-pane btn so that focus is not just lost.
if (!open && this._window.document.activeElement.dataset.action == "toggle-pane") {
// Context pane collapsed when sidenav button is focused - try to focus btn in reader toolbar
setTimeout(() => {
this._iframeWindow.document.querySelector(".context-pane-toggle").focus({ focusVisible: true });
});
}
else if (open && this._iframeWindow.document.activeElement.classList.contains("context-pane-toggle")) {
// Context pane expanded when toggle-pane in reader toolbar is focused.
// Try to focus the sidenav button, if reader's button was hidden
setTimeout(() => {
if (this._iframeWindow.document.querySelector("context-pane-toggle")) return;
this._window.document.querySelector("#zotero-context-pane-sidenav .btn[data-action='toggle-pane']").focus({ focusVisible: true });
});
}
this._internalReader.setContextPaneOpen(open);
}