mordoc 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/app/main.tsx +10 -0
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/shiva-varanasi/mordoc.git"
6
6
  },
7
- "version": "1.2.0",
7
+ "version": "1.2.1",
8
8
  "description": "A modern documentation site generator powered by Vite, React, and Markdoc.",
9
9
  "type": "module",
10
10
  "files": [
package/src/app/main.tsx CHANGED
@@ -34,6 +34,16 @@ import 'virtual:mordoc/theme';
34
34
  * triggering a redundant fetch of the same lazy page chunk that the
35
35
  * server already used to produce the initial HTML.
36
36
  */
37
+ // React Router's beforeunload handler saves scroll position to sessionStorage
38
+ // on every page exit — including reloads — so the next load restores it,
39
+ // causing a visible jump from top to the saved position. Clearing the entry
40
+ // here (after the reload, before hydrateRoot) prevents the restoration.
41
+ if ((performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming | undefined)?.type === 'reload') {
42
+ try {
43
+ sessionStorage.removeItem('react-router-scroll-positions');
44
+ } catch { /* unavailable in some private-browsing modes */ }
45
+ }
46
+
37
47
  const container = document.getElementById('app');
38
48
  if (!container) {
39
49
  throw new Error('mordoc: #app element not found in HTML shell');