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.
This commit is contained in:
James Teh 2022-11-24 02:19:42 +10:00 committed by GitHub
parent 6b1533c947
commit a447b9535e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}