mirror of
https://github.com/dergigi/boris.git
synced 2026-02-23 16:04:29 +01:00
fix: reset scroll position when switching articles
Reset scroll position to top immediately when articleIdentifier changes to prevent showing wrong scroll position from previous article. Also reset hasAttemptedRestoreRef when article changes to ensure proper scroll restoration for new articles.
This commit is contained in:
@@ -263,6 +263,15 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
const restoreKey = `${articleIdentifier}-${isTrackingEnabled}`
|
||||
const hasAttemptedRestoreRef = useRef<string | null>(null)
|
||||
|
||||
// Reset scroll position and restore ref when article changes
|
||||
useEffect(() => {
|
||||
// Reset scroll to top when article identifier changes
|
||||
// This prevents showing wrong scroll position from previous article
|
||||
window.scrollTo({ top: 0, behavior: 'instant' })
|
||||
// Reset restore attempt tracking for new article
|
||||
hasAttemptedRestoreRef.current = null
|
||||
}, [articleIdentifier])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isTextContent || !activeAccount || !articleIdentifier) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user