@docusaurus/core 0.0.0-5407 → 0.0.0-5408

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.
@@ -14,7 +14,17 @@ export function dispatchLifecycleAction(lifecycleAction, ...args) {
14
14
  });
15
15
  return () => callbacks.forEach((cb) => cb?.());
16
16
  }
17
- function scrollAfterNavigation(location) {
17
+ function scrollAfterNavigation({ location, previousLocation, }) {
18
+ if (!previousLocation) {
19
+ return; // no-op: use native browser feature
20
+ }
21
+ const samePathname = location.pathname === previousLocation.pathname;
22
+ const sameHash = location.hash === previousLocation.hash;
23
+ const sameSearch = location.search === previousLocation.search;
24
+ // Query-string changes: do not scroll to top/hash
25
+ if (samePathname && sameHash && !sameSearch) {
26
+ return;
27
+ }
18
28
  const { hash } = location;
19
29
  if (!hash) {
20
30
  window.scrollTo(0, 0);
@@ -28,9 +38,7 @@ function scrollAfterNavigation(location) {
28
38
  function ClientLifecyclesDispatcher({ children, location, previousLocation, }) {
29
39
  useLayoutEffect(() => {
30
40
  if (previousLocation !== location) {
31
- if (previousLocation) {
32
- scrollAfterNavigation(location);
33
- }
41
+ scrollAfterNavigation({ location, previousLocation });
34
42
  dispatchLifecycleAction('onRouteDidUpdate', { previousLocation, location });
35
43
  }
36
44
  }, [previousLocation, location]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "0.0.0-5407",
4
+ "version": "0.0.0-5408",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -43,13 +43,13 @@
43
43
  "@babel/runtime": "^7.19.0",
44
44
  "@babel/runtime-corejs3": "^7.19.0",
45
45
  "@babel/traverse": "^7.19.0",
46
- "@docusaurus/cssnano-preset": "0.0.0-5407",
47
- "@docusaurus/logger": "0.0.0-5407",
48
- "@docusaurus/mdx-loader": "0.0.0-5407",
46
+ "@docusaurus/cssnano-preset": "0.0.0-5408",
47
+ "@docusaurus/logger": "0.0.0-5408",
48
+ "@docusaurus/mdx-loader": "0.0.0-5408",
49
49
  "@docusaurus/react-loadable": "5.5.2",
50
- "@docusaurus/utils": "0.0.0-5407",
51
- "@docusaurus/utils-common": "0.0.0-5407",
52
- "@docusaurus/utils-validation": "0.0.0-5407",
50
+ "@docusaurus/utils": "0.0.0-5408",
51
+ "@docusaurus/utils-common": "0.0.0-5408",
52
+ "@docusaurus/utils-validation": "0.0.0-5408",
53
53
  "@slorber/static-site-generator-webpack-plugin": "^4.0.7",
54
54
  "@svgr/webpack": "^6.3.1",
55
55
  "autoprefixer": "^10.4.8",
@@ -106,8 +106,8 @@
106
106
  "webpackbar": "^5.0.2"
107
107
  },
108
108
  "devDependencies": {
109
- "@docusaurus/module-type-aliases": "0.0.0-5407",
110
- "@docusaurus/types": "0.0.0-5407",
109
+ "@docusaurus/module-type-aliases": "0.0.0-5408",
110
+ "@docusaurus/types": "0.0.0-5408",
111
111
  "@types/detect-port": "^1.3.2",
112
112
  "@types/react-dom": "^18.0.6",
113
113
  "@types/react-router-config": "^5.0.6",
@@ -127,5 +127,5 @@
127
127
  "engines": {
128
128
  "node": ">=16.14"
129
129
  },
130
- "gitHead": "90e2f775557394e9e5e4b392258d33b38dceb9ca"
130
+ "gitHead": "6d1f31ee146538494968633a12e92c47cd3de973"
131
131
  }