mirror of
https://github.com/zotero/zotero.git
synced 2026-10-03 02:21:49 +00:00
Keep tabs menu focus when using up/down (#5346)
This commit is contained in:
parent
46f879dcdb
commit
cc4c8cd191
1 changed files with 19 additions and 1 deletions
|
|
@ -356,6 +356,21 @@
|
|||
this.resetFocus();
|
||||
}
|
||||
|
||||
cacheFocus() {
|
||||
if (this._selectedIndex === 0) {
|
||||
// The first tab row does not have focusable elements
|
||||
return;
|
||||
}
|
||||
let activeElement = document.activeElement;
|
||||
if (this.contains(activeElement)) {
|
||||
if (activeElement.classList.contains("close")) {
|
||||
this._prevFocusClass = "close";
|
||||
return;
|
||||
}
|
||||
}
|
||||
this._prevFocusClass = null;
|
||||
}
|
||||
|
||||
resetFocus() {
|
||||
let row = this._tabsList.querySelector(".selected");
|
||||
if (this._prevFocusClass) {
|
||||
|
|
@ -464,14 +479,17 @@
|
|||
_handleKeydown = (event) => {
|
||||
if (["Home", "PageUp"].includes(event.key)) {
|
||||
event.preventDefault();
|
||||
this.cacheFocus();
|
||||
this.moveSelection("first");
|
||||
}
|
||||
else if (["End", "PageDown"].includes(event.key)) {
|
||||
event.preventDefault();
|
||||
this.cacheFocus();
|
||||
this.moveSelection("last");
|
||||
}
|
||||
else if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
||||
event.preventDefault();
|
||||
this.cacheFocus();
|
||||
if (event.key == "ArrowDown") {
|
||||
this.moveSelection("next");
|
||||
}
|
||||
|
|
@ -497,8 +515,8 @@
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
// Move selection to the next tab to make sure the next tab's close button is focused
|
||||
this.cacheFocus();
|
||||
this.moveSelection("next");
|
||||
this._prevFocusClass = "close";
|
||||
this._handleCloseClick(event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue