diff --git a/src/components/AnnotationViews/AnnotationPageView.tsx b/src/components/AnnotationViews/AnnotationPageView.tsx index 1cb6d4e..80d458e 100644 --- a/src/components/AnnotationViews/AnnotationPageView.tsx +++ b/src/components/AnnotationViews/AnnotationPageView.tsx @@ -34,6 +34,14 @@ export default function AnnotationPageView({ const [isCalibrationModalOpen, setIsCalibrationModalOpen] = useState(false); const [dialectScores, setDialectScores] = useState>({}); + // Scroll to top on component mount + useEffect(() => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }, []); + // Load calibration scores on component mount useEffect(() => { const loadScores = async () => { diff --git a/src/components/CalibrationViews/CalibrationEntryView.tsx b/src/components/CalibrationViews/CalibrationEntryView.tsx index 16ed204..5afe401 100644 --- a/src/components/CalibrationViews/CalibrationEntryView.tsx +++ b/src/components/CalibrationViews/CalibrationEntryView.tsx @@ -49,10 +49,16 @@ export default function CalibrationEntryView({ setSelectedDialect(existingAnswer?.dialectLabel || null); setSelectedConfidence(existingAnswer?.confidence || null); setFullyPlayed(existingAnswer ? true : false); - // Scroll to top when entry changes with smooth animation - window.scrollTo({ top: 0, behavior: 'smooth' }); }, [entry, existingAnswer]); + useEffect(() => { + // Scroll to top when entry changes + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }, [entry.id]); + return (
void; hasExistingAnswers: boolean; @@ -9,6 +11,13 @@ export default function CalibrationInfoView({ onContinue, hasExistingAnswers, }: CalibrationInfoViewProps) { + useEffect(() => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }, []); + const handleContinue = () => { onContinue(); }; diff --git a/src/components/CalibrationViews/CalibrationPhase.tsx b/src/components/CalibrationViews/CalibrationPhase.tsx index 536f04d..c082080 100644 --- a/src/components/CalibrationViews/CalibrationPhase.tsx +++ b/src/components/CalibrationViews/CalibrationPhase.tsx @@ -6,6 +6,13 @@ import { ExperimentCalibration } from '@/lib/model/experiment_calibration'; import CalibrationPageView from './CalibrationPageView'; import CalibrationInfoView from './CalibrationInfoView'; +const scrollToTop = () => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); +}; + interface CalibrationPhaseProps { experimentId: number; } @@ -61,12 +68,14 @@ export default function CalibrationPhase({ experimentId }: CalibrationPhaseProps if (showInfoPage) { return ( setShowInfoPage(false)} + onContinue={() => { + scrollToTop(); + setShowInfoPage(false); + }} hasExistingAnswers={hasExistingAnswers} /> ); } - // Show calibration page return ; }