diff --git a/chrome/content/zotero/selectItemsDialog.js b/chrome/content/zotero/selectItemsDialog.js index b86f432888..f4bdf51c43 100644 --- a/chrome/content/zotero/selectItemsDialog.js +++ b/chrome/content/zotero/selectItemsDialog.js @@ -104,6 +104,19 @@ var doLoad = async function () { document.addEventListener('dialogaccept', doAccept); + if (isSelectItemsDialog) { + // Set proper tab order. It is only needed in selectItemsDialog -- other dialogs' focus order is correct + document.querySelector("#zotero-tb-search").searchModePopup.parentNode.setAttribute("tabindex", 1); + document.querySelector("#zotero-tb-search").searchTextbox.inputField.setAttribute("tabindex", 2); + document.querySelector("#collection-tree").setAttribute("tabindex", 3); + document.querySelector("#zotero-items-tree .virtualized-table").setAttribute("tabindex", 4); + // On Windows, buttons are in a different order than on macOS, so set tabindex accordingly + let nextButtonTabindex = 5; + for (let button of [...document.querySelectorAll("button[dlgtype]:not([hidden])")]) { + button.setAttribute("tabindex", nextButtonTabindex++); + } + } + // Used in tests loaded = true; };