Skip to content

Commit 5ee127f

Browse files
committed
Fix supertab freezing the app
Removes pointless conditions and the infinite, app-freezing while-loop.
1 parent 02e7a9e commit 5ee127f

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

ts/services/addGlobalKeyboardShortcuts.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function addGlobalKeyboardShortcuts(): void {
4242
return;
4343
}
4444

45-
// Super tab :)
45+
// Super tab :(
4646
if (
4747
(commandOrCtrl && key === 'F6') ||
4848
(commandOrCtrl && !shiftKey && (key === 't' || key === 'T'))
@@ -55,10 +55,7 @@ export function addGlobalKeyboardShortcuts(): void {
5555
const focusedIndexes: Array<number> = [];
5656

5757
targets.forEach((target, index) => {
58-
if (
59-
(focusedElement != null && target === focusedElement) ||
60-
target.contains(focusedElement)
61-
) {
58+
if (target.contains(focusedElement)) {
6259
focusedIndexes.push(index);
6360
}
6461
});
@@ -75,22 +72,7 @@ export function addGlobalKeyboardShortcuts(): void {
7572
// elements match (generally going to be a parent element)
7673
const focusedIndex = focusedIndexes.at(-1) ?? -1;
7774

78-
const lastIndex = targets.length - 1;
79-
const increment = shiftKey ? -1 : 1;
80-
81-
let index;
82-
if (focusedIndex < 0 || focusedIndex >= lastIndex) {
83-
index = 0;
84-
} else {
85-
index = focusedIndex + increment;
86-
}
87-
88-
while (!targets[index]) {
89-
index += increment;
90-
if (index > lastIndex || index < 0) {
91-
index = 0;
92-
}
93-
}
75+
const index = (focusedIndex + 1) % targets.length;
9476

9577
const node = targets[index];
9678
const firstFocusableElement = matchOrQueryFocusable(node);

0 commit comments

Comments
 (0)