Don't scroll to the top when navigating between posts in a thread

Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1778
merge-requests/3241/head
Alex Gleason 2024-11-10 12:07:51 -06:00
rodzic f41e5e3f6b
commit 662d2aaf93
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -9,6 +9,12 @@ export const ScrollContext: React.FC<IScrollContext> = ({ children }) => {
const location = useLocation<{ soapboxModalKey?: number } | undefined>();
useEffect(() => {
// HACK: Don't scroll when navigating between posts.
// Surely there's a better way, so that components can negate the behavior from within instead of out here.
if (location.pathname.includes('/posts/')) {
return;
}
if (!location.state?.soapboxModalKey) {
window.scrollTo(0, 0);
}