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.
- package/package.json +1 -1
- package/src/app/main.tsx +10 -0
package/package.json
CHANGED
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');
|