Skip to content

Commit 9c68656

Browse files
committed
fix: set scrollRestoration=manual to prevent scroll reset on URL param sync
history.replaceState() for filters/groupBy/period was triggering browser scroll restoration to position 0 since scrollRestoration defaulted to 'auto'
1 parent c867e68 commit 9c68656

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import App from './App';
88
import { ThemeContext } from './context/theme-context';
99
import './global.css';
1010

11+
// Prevent browser from auto-resetting scroll position when we call
12+
// history.replaceState() to sync URL params (filters, groupBy, period, etc.)
13+
if ('scrollRestoration' in history) {
14+
history.scrollRestoration = 'manual';
15+
}
16+
1117
export default function Root() {
1218
const [colorMode, setColorMode] = useState<'auto' | 'day' | 'night'>(() => {
1319
const stored = localStorage.getItem('tbb-color-mode');

0 commit comments

Comments
 (0)