fix: add save suppression when resetting scroll position

Add 500ms save suppression when article changes to prevent
accidentally saving 0% reading position during navigation.
This works together with existing safeguards (tracking disabled,
document height check, throttling) to ensure reading progress
is only saved during actual reading.
This commit is contained in:
Gigi
2025-10-31 01:37:02 +01:00
parent 826f07544e
commit 5a6ac628d2

View File

@@ -265,6 +265,14 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
// Reset scroll position and restore ref when article changes
useEffect(() => {
if (!articleIdentifier) return
// Suppress saves during navigation to prevent saving 0% position
// The 500ms suppression covers the scroll reset and initial render
if (suppressSavesForRef.current) {
suppressSavesForRef.current(500)
}
// Reset scroll to top when article identifier changes
// This prevents showing wrong scroll position from previous article
window.scrollTo({ top: 0, behavior: 'instant' })