fix: make shortcuts operate relative to the parent toot (#2229)

Previously, if focus was on an element inside a toot instead of the toot itself (e.g. moving to a toot and pressing tab), keyboard commands acted as if no toot was active.
In particular, this meant that the arrow keys scrolled to the first visible toot.
Fixes #2228.
scrollFix
James Teh 2022-11-24 02:19:42 +10:00 zatwierdzone przez GitHub
rodzic 6b1533c947
commit a447b9535e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -119,7 +119,13 @@
if (!activeElement) {
return null
}
const activeItem = activeElement.getAttribute('id')
// The user might be focused on an element inside a toot. We want to
// move relative to that toot.
const activeArticle = activeElement.closest('article')
if (!activeArticle) {
return null
}
const activeItem = activeArticle.getAttribute('id')
if (!activeItem) {
return null
}