Merge branch 'thread-scroll' into 'main'
Don't scroll to the top when navigating between posts in a thread Closes #1778 See merge request soapbox-pub/soapbox!3231
This commit is contained in:
commit
482c69d2d2
|
@ -9,6 +9,12 @@ export const ScrollContext: React.FC<IScrollContext> = ({ children }) => {
|
||||||
const location = useLocation<{ soapboxModalKey?: number } | undefined>();
|
const location = useLocation<{ soapboxModalKey?: number } | undefined>();
|
||||||
|
|
||||||
useEffect(() => {
|
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) {
|
if (!location.state?.soapboxModalKey) {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue