From 71af85adb3229b3cbc93597d72b196691806cebd Mon Sep 17 00:00:00 2001 From: abaevbog Date: Fri, 3 Nov 2023 18:14:50 -0400 Subject: [PATCH] minor fixes to keyboard navigation 1. Swap focus direction for ArrowUp and ArrowDown events when applicable. ArrowUp = Shift-Tab, ArrowDown - Tab. 2. Remove ArrowLeft, ArrowRight event listeners from quicksearch menus to not prevent cursor navigation within the actual text field. 3. Tweaks to fix advanced search mode from quicksearch when " is typed. --- chrome/content/zotero/zoteroPane.js | 16 ++++++---------- chrome/content/zotero/zoteroPane.xhtml | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 2c7b5bbccd..cf337aa4f6 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -160,14 +160,14 @@ var ZoteroPane = new function() // function to handle actual focusing based on a given event // and a mapping of event targets + keys to the focus destinations let moveFocus = function (actionsMap, event, verticalArrowIsTab = false) { + var key = event.key; if (key === 'Tab' && modifierIsNotShift(event)) return; - var key = event.key; if (event.shiftKey) { key = 'Shift' + key; } // ArrowUp or ArrowDown act the same way as as - // tab/shift-tab unles it is on a menu, in which case + // shift-tab/tab unles it is on a menu, in which case // it'll open the menu popup let isMenu = event.target.getAttribute('type') === 'menu' || event.originalTarget?.getAttribute('type') === 'menu'; @@ -175,10 +175,10 @@ var ZoteroPane = new function() return; } if (verticalArrowIsTab && key == 'ArrowUp') { - key = 'Tab'; + key = 'ShiftTab'; } else if (verticalArrowIsTab && key == 'ArrowDown') { - key = 'ShiftTab'; + key = 'Tab'; } let focusFunction = actionsMap[event.target.id]?.[key]; // If the focusFunction is undefined, nothing was found @@ -256,7 +256,7 @@ var ZoteroPane = new function() .dispatchEvent(new MouseEvent("click", { target: event.target })) } }; - moveFocus(actionsMap, event); + moveFocus(actionsMap, event, true); }); collectionTreeToolbar.addEventListener("keydown", (event) => { @@ -268,8 +268,6 @@ var ZoteroPane = new function() ShiftTab: () => document.getElementById('zotero-tb-sync') }, 'zotero-collections-search': { - ArrowRight: () => null, - ArrowLeft: () => null, Tab: () => document.getElementById('zotero-tb-add'), ShiftTab: () => document.getElementById('zotero-tb-collection-add') }, @@ -324,8 +322,6 @@ var ZoteroPane = new function() ShiftTab: () => document.getElementById('zotero-tb-collection-search').click() }, 'zotero-tb-search-textbox': { - ArrowRight: () => null, - ArrowLeft: () => null, ShiftTab: () => { document.getElementById("zotero-tb-search")._searchModePopup.flattenedTreeParentNode.focus(); }, @@ -2728,7 +2724,7 @@ var ZoteroPane = new function() this.handleSearchInput = function (textbox, event) { - if (textbox.value.indexOf('"') != -1) { + if (textbox.searchTextbox.value.indexOf('"') != -1) { this.setItemsPaneMessage(Zotero.getString('advancedSearchMode')); } } diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml index eee537f200..3a7e4dfd65 100644 --- a/chrome/content/zotero/zoteroPane.xhtml +++ b/chrome/content/zotero/zoteroPane.xhtml @@ -1031,7 +1031,7 @@