From d69828755807bd1262b5157edca04539ca9c1166 Mon Sep 17 00:00:00 2001 From: abaevbog Date: Mon, 25 Nov 2024 23:27:55 -0800 Subject: [PATCH] context notes pane focus fixes (#4864) - shift-tab from a note row focuses section header's twisty - tab from reader into context pane will focus search field. Previously focused note row will be focused on tab from a section header's twisty - fix focus not leaving context notes pane if all sections are collapsed - shift-tab from sidenav will focus the last node in the contextPane, instead of search input. That is to have consistent tab order in each direction. Fixes: #4858 --- chrome/content/zotero/elements/contextNotesList.js | 13 +++++++------ chrome/content/zotero/elements/itemPaneSidenav.js | 2 +- chrome/content/zotero/elements/notesContext.js | 5 +---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/elements/contextNotesList.js b/chrome/content/zotero/elements/contextNotesList.js index 969aebc790..7721ee4cf7 100644 --- a/chrome/content/zotero/elements/contextNotesList.js +++ b/chrome/content/zotero/elements/contextNotesList.js @@ -202,14 +202,16 @@ }; // ArrowUp/Down navigation between notes - // Tab from a note-row focuses sidenav, Shift-Tab from a note focuses the section header + // Tab from a note-row focuses sidenav, Shift-Tab from a note focuses the twisty of the section header // Tab from twisty icon into the notes list will try to refocus the last focused note _handleKeyDown = (event) => { - if (event.key == "Tab" && event.target.classList.contains("twisty")) { + if (event.key == "Tab" && !event.shiftKey && event.target.classList.contains("twisty")) { let section = event.target.closest("collapsible-section"); if (this._lastFocusedNote && section.contains(this._lastFocusedNote)) { - this.refocusLastFocusedNote(); - event.preventDefault(); + let refocused = this.refocusLastFocusedNote(); + if (refocused) { + event.preventDefault(); + } } } if (event.target.tagName !== "note-row" && !event.target.classList.contains("more")) return; @@ -225,8 +227,7 @@ event.preventDefault(); } else if (event.key == "Tab" && event.shiftKey) { - Services.focus.moveFocus(window, event.target.closest("collapsible-section"), - Services.focus.MOVEFOCUS_FORWARD, 0); + event.target.closest("collapsible-section").querySelector(".twisty").focus(); event.preventDefault(); } }; diff --git a/chrome/content/zotero/elements/itemPaneSidenav.js b/chrome/content/zotero/elements/itemPaneSidenav.js index 9a9a968da9..89b918f6ff 100644 --- a/chrome/content/zotero/elements/itemPaneSidenav.js +++ b/chrome/content/zotero/elements/itemPaneSidenav.js @@ -392,7 +392,7 @@ if (event.key == "Tab" && event.shiftKey) { event.preventDefault(); if (this._contextNotesPaneVisible && this._contextNotesPane.selectedPanel.mode == "notesList") { - let focusHandled = this._contextNotesPane.selectedPanel.focus(); + let focusHandled = this._contextNotesPane.selectedPanel.notesList.refocusLastFocusedNote(); if (focusHandled) return; } // Shift-Tab out of sidenav to itemPane diff --git a/chrome/content/zotero/elements/notesContext.js b/chrome/content/zotero/elements/notesContext.js index dba5b19932..de506c4c30 100644 --- a/chrome/content/zotero/elements/notesContext.js +++ b/chrome/content/zotero/elements/notesContext.js @@ -152,10 +152,7 @@ focus() { if (this.mode == "notesList") { - let refocused = this.notesList.refocusLastFocusedNote(); - if (!refocused) { - this.input.focus(); - } + this.input.focus(); return true; } else {