vpat: 4 change focus sequence in zotero pane (#3954)
From the sync button, tabbing will move focus in the following mannger: collections toolbar -> collections -> tags selector -> itemTree toolbar -> itemTree.
This commit is contained in:
parent
9421e09e84
commit
68596148b0
1 changed files with 26 additions and 28 deletions
|
@ -321,6 +321,20 @@ var ZoteroPane = new function()
|
||||||
ZoteroPane.hideCollectionSearch();
|
ZoteroPane.hideCollectionSearch();
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
let focusCollectionTree = () => {
|
||||||
|
// Prevent Enter/Tab pressed before the filtering ran from doing anything
|
||||||
|
if (!ZoteroPane.collectionsView.filterEquals(collectionsSearchField.value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// If the current row passes the filter, make sure it is visible and focus collectionTree
|
||||||
|
if (ZoteroPane.collectionsView.focusedRowMatchesFilter()) {
|
||||||
|
ZoteroPane.collectionsView.ensureRowIsVisible(ZoteroPane.collectionsView.selection.focused);
|
||||||
|
return document.getElementById('collection-tree');
|
||||||
|
}
|
||||||
|
// Otherwise, focus the first row passing the filter
|
||||||
|
ZoteroPane.collectionsView.focusFirstMatchingRow(false);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
collectionTreeToolbar.addEventListener("keydown", (event) => {
|
collectionTreeToolbar.addEventListener("keydown", (event) => {
|
||||||
let actionsMap = {
|
let actionsMap = {
|
||||||
'zotero-tb-collection-add': {
|
'zotero-tb-collection-add': {
|
||||||
|
@ -330,22 +344,9 @@ var ZoteroPane = new function()
|
||||||
ShiftTab: () => document.getElementById('zotero-tb-sync')
|
ShiftTab: () => document.getElementById('zotero-tb-sync')
|
||||||
},
|
},
|
||||||
'zotero-collections-search': {
|
'zotero-collections-search': {
|
||||||
Tab: () => document.getElementById('zotero-tb-add'),
|
Tab: focusCollectionTree,
|
||||||
ShiftTab: () => document.getElementById('zotero-tb-collection-add'),
|
ShiftTab: () => document.getElementById('zotero-tb-collection-add'),
|
||||||
Enter: () => {
|
Enter: focusCollectionTree,
|
||||||
// Prevent Enter pressed before the filtering ran from doing anything
|
|
||||||
if (!ZoteroPane.collectionsView.filterEquals(collectionsSearchField.value)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// If the current row passes the filter, make sure it is visible and focus collectionTree
|
|
||||||
if (ZoteroPane.collectionsView.focusedRowMatchesFilter()) {
|
|
||||||
ZoteroPane.collectionsView.ensureRowIsVisible(ZoteroPane.collectionsView.selection.focused);
|
|
||||||
return document.getElementById('collection-tree');
|
|
||||||
}
|
|
||||||
// Otherwise, focus the first row passing the filter
|
|
||||||
ZoteroPane.collectionsView.focusFirstMatchingRow(false);
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
Escape: clearCollectionSearch
|
Escape: clearCollectionSearch
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -362,8 +363,10 @@ var ZoteroPane = new function()
|
||||||
if (collectionsPane.getAttribute("collapsed")) {
|
if (collectionsPane.getAttribute("collapsed")) {
|
||||||
return document.getElementById('zotero-tb-sync');
|
return document.getElementById('zotero-tb-sync');
|
||||||
}
|
}
|
||||||
document.getElementById('zotero-tb-collections-search').click();
|
if (tagContainer.getAttribute('collapsed') == "true") {
|
||||||
return null;
|
return focusCollectionTree();
|
||||||
|
}
|
||||||
|
return document.querySelector("#zotero-tag-selector button");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'zotero-tb-lookup': {
|
'zotero-tb-lookup': {
|
||||||
|
@ -390,7 +393,7 @@ var ZoteroPane = new function()
|
||||||
ShiftTab: () => {
|
ShiftTab: () => {
|
||||||
document.getElementById("zotero-tb-search")._searchModePopup.flattenedTreeParentNode.focus();
|
document.getElementById("zotero-tb-search")._searchModePopup.flattenedTreeParentNode.focus();
|
||||||
},
|
},
|
||||||
Tab: () => document.getElementById("collection-tree")
|
Tab: () => document.getElementById('item-tree-main-default')
|
||||||
},
|
},
|
||||||
'zotero-tb-search-dropmarker': {
|
'zotero-tb-search-dropmarker': {
|
||||||
ArrowRight: () => null,
|
ArrowRight: () => null,
|
||||||
|
@ -405,12 +408,12 @@ var ZoteroPane = new function()
|
||||||
collectionsTree.addEventListener("keydown", (event) => {
|
collectionsTree.addEventListener("keydown", (event) => {
|
||||||
let actionsMap = {
|
let actionsMap = {
|
||||||
'collection-tree': {
|
'collection-tree': {
|
||||||
ShiftTab: () => document.getElementById("zotero-tb-search-textbox"),
|
ShiftTab: () => document.getElementById('zotero-tb-collections-search').click(),
|
||||||
Tab: () => {
|
Tab: () => {
|
||||||
if (tagContainer.getAttribute('collapsed') == "true") {
|
if (tagContainer.getAttribute('collapsed') == "true") {
|
||||||
return document.getElementById('item-tree-main-default');
|
return document.getElementById('zotero-tb-add');
|
||||||
}
|
}
|
||||||
// If tag selector is collapsed, go to itemTree, otherwise
|
// If tag selector is collapsed, go to "New item" button, otherwise
|
||||||
// default to focusing on tag selector
|
// default to focusing on tag selector
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -423,12 +426,7 @@ var ZoteroPane = new function()
|
||||||
itemTree.addEventListener("keydown", (event) => {
|
itemTree.addEventListener("keydown", (event) => {
|
||||||
let actionsMap = {
|
let actionsMap = {
|
||||||
'item-tree-main-default': {
|
'item-tree-main-default': {
|
||||||
ShiftTab: () => {
|
ShiftTab: () => document.getElementById('zotero-tb-search-textbox')
|
||||||
if (tagContainer.getAttribute('collapsed') == "true") {
|
|
||||||
return document.getElementById('collection-tree');
|
|
||||||
}
|
|
||||||
return document.getElementById('zotero-tag-selector').querySelector('button');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
moveFocus(actionsMap, event);
|
moveFocus(actionsMap, event);
|
||||||
|
@ -455,7 +453,7 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
// Special treatment for tag selector button because it has no id
|
// Special treatment for tag selector button because it has no id
|
||||||
if (e.target.tagName == "button" && e.key == "Tab" && !e.shiftKey) {
|
if (e.target.tagName == "button" && e.key == "Tab" && !e.shiftKey) {
|
||||||
document.getElementById('item-tree-main-default').focus();
|
document.getElementById('zotero-tb-add').focus();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue