diff --git a/src/App.jsx b/src/App.jsx index 055e25c..5521446 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -76,7 +76,6 @@ export default function App() { setView(nextView) setActiveModuleIdx(mIdx) setActiveLessonIdx(lIdx) - window.scrollTo({ top: 0, behavior: 'instant' }) } const openLesson = (mIdx, lIdx) => navigate('lesson', mIdx, lIdx) diff --git a/src/components/LessonView.jsx b/src/components/LessonView.jsx index 113592e..f7a3724 100644 --- a/src/components/LessonView.jsx +++ b/src/components/LessonView.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useState, useEffect } from 'react' import Markdown from './Markdown' import CodeBlock from './CodeBlock' @@ -25,6 +25,10 @@ export default function LessonView({ }) { const [activeTab, setActiveTab] = useState('theory') + useEffect(() => { + window.scrollTo({ top: 0, behavior: 'instant' }) + }, [lesson.id]) + const tabs = [ { key: 'theory', icon: '📖', label: labels.theory, disabled: false }, { key: 'code', icon: '💻', label: labels.code, disabled: !lesson.codeBlocks?.length },