From 0e77779f1ecd0c60bccea7e923e45aaef60b9dc3 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 10 May 2023 22:20:59 +0200 Subject: [PATCH] fix retained scroll position while navigating --- src/components/views/Board.jsx | 11 ++++++----- src/components/views/Catalog.jsx | 7 ++++--- src/components/views/Home.jsx | 7 +++++-- src/components/views/Pending.jsx | 8 ++++---- src/components/views/SubscriptionsCatalog.jsx | 3 ++- src/components/views/Thread.jsx | 7 +++---- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index c2562d50..cbe85158 100644 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -422,8 +422,7 @@ const Board = () => {
setIsSettingsOpen(true)}>Settings   - handleStyleChange({target: {value: "Yotsuba"}} - )}>Home + {handleStyleChange({target: {value: "Yotsuba"}}); window.scrollTo(0, 0);}}>Home
 
@@ -508,7 +507,7 @@ const Board = () => {
[ - Catalog + {window.scrollTo(0, 0)}}>Catalog ]
{feed.length > 0 ? ( @@ -531,7 +530,7 @@ const Board = () => { )}
- Catalog + {window.scrollTo(0, 0)}}>Catalog
@@ -1012,7 +1011,9 @@ const Board = () => { ((thread.replyCount + pendingReplyCounts[thread.cid]) + " replies") : null } - setSelectedThread(thread.cid)} className="button-mobile" >View Thread + {setSelectedThread(thread.cid); window.scrollTo(0, 0);}} + className="button-mobile" >View Thread {displayedReplies?.map((reply, index) => { diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index bd9f8ba5..fdb7a5a6 100644 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -422,7 +422,7 @@ const Catalog = () => {
[ - Return + {window.scrollTo(0, 0)}}>Return ]
{feed.length > 0 ? ( @@ -445,7 +445,7 @@ const Catalog = () => { )}
- Return + {window.scrollTo(0, 0)}}>Return

@@ -465,7 +465,8 @@ const Catalog = () => { const commentMediaInfo = getCommentMediaInfo(thread); const fallbackImgUrl = "assets/filedeleted-res.gif"; return ( - setSelectedThread(thread.cid)}> + {setSelectedThread(thread.cid); window.scrollTo(0, 0);}}>
{commentMediaInfo?.url ? ( diff --git a/src/components/views/Home.jsx b/src/components/views/Home.jsx index 84afdb05..df154d16 100644 --- a/src/components/views/Home.jsx +++ b/src/components/views/Home.jsx @@ -98,11 +98,13 @@ const Home = () => {

You have subscribed to {account?.subscriptions?.length} board{account?.subscriptions?.length > 1 ? "s" : null}

  - [view all] + {window.scrollTo(0, 0)}}>[view all]
{account?.subscriptions?.map((subscription, index) => ( <> - + {window.scrollTo(0, 0)}} + to={`/p/${subscription}`}>
{subscription}  { { setSelectedTitle(subplebbit.title); setSelectedAddress(subplebbit.address); + window.scrollTo(0, 0); }} > diff --git a/src/components/views/Pending.jsx b/src/components/views/Pending.jsx index 944f6c86..4fd1a96a 100644 --- a/src/components/views/Pending.jsx +++ b/src/components/views/Pending.jsx @@ -160,12 +160,12 @@ const Pending = () => {
- Return + {window.scrollTo(0, 0)}}>Return
- Catalog + {window.scrollTo(0, 0)}}>Catalog
 
@@ -187,12 +187,12 @@ const Pending = () => { [ - Return + {window.scrollTo(0, 0)}}>Return ] [ - Catalog + {window.scrollTo(0, 0)}}>Catalog ] {stateString} diff --git a/src/components/views/SubscriptionsCatalog.jsx b/src/components/views/SubscriptionsCatalog.jsx index bbfd7694..80e1d2b2 100644 --- a/src/components/views/SubscriptionsCatalog.jsx +++ b/src/components/views/SubscriptionsCatalog.jsx @@ -214,7 +214,8 @@ const SubscriptionsCatalog = () => { const commentMediaInfo = getCommentMediaInfo(thread); const fallbackImgUrl = "assets/filedeleted-res.gif"; return ( - setSelectedThread(thread.cid)}> + {setSelectedThread(thread.cid); window.scrollTo(0, 0);}}>
{commentMediaInfo?.url ? ( diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index 47029d09..c7cf58b7 100644 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -360,8 +360,7 @@ const Thread = () => {
setIsSettingsOpen(true)}>Settings   - handleStyleChange({target: {value: "Yotsuba"}} - )}>Home + {handleStyleChange({target: {value: "Yotsuba"}}); window.scrollTo(0, 0);}}>Home
 
@@ -388,13 +387,13 @@ const Thread = () => {
- + {window.scrollTo(0, 0)}}> Return
- Catalog + {window.scrollTo(0, 0)}}>Catalog