FIX: lockup when navigating with j/k (#30674)

If, for some reasons, navigating between posts using j/k keyboard
shortcuts does not select any posts, there could be an infinite loop
due to setting the `direction` to `0` and then using it do "iterate"
over the arrays of available "articles".

Despite many attemps, I wasn't able to reproduce the issue reported in
https://dev.discourse.org/t/145565 so this is somewhat of a shot in the
dark.
This commit is contained in:
Régis Hanol 2025-01-09 20:38:44 +01:00 committed by GitHub
parent c39893364b
commit 773857848b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -775,6 +775,11 @@ export default {
if (article.getBoundingClientRect().height > 0) {
break;
}
// Safeguard against infinite loops
if (direction === 0) {
break;
}
}
for (const a of articles) {