@docusaurus/theme-classic 4.0.0-canary-6833 → 4.0.0-canary-6835
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.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, {useEffect, useMemo} from 'react';
|
|
7
|
+
import React, {useEffect, useMemo, useState} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import {
|
|
10
10
|
ThemeClassNames,
|
|
@@ -181,7 +181,11 @@ function DocSidebarItemCategoryCollapsible({
|
|
|
181
181
|
updateCollapsed,
|
|
182
182
|
activePath,
|
|
183
183
|
});
|
|
184
|
-
|
|
184
|
+
// Collapse when a sibling category gets expanded
|
|
185
|
+
// See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
186
|
+
const [prevExpandedItem, setPrevExpandedItem] = useState(expandedItem);
|
|
187
|
+
if (expandedItem !== prevExpandedItem) {
|
|
188
|
+
setPrevExpandedItem(expandedItem);
|
|
185
189
|
if (
|
|
186
190
|
collapsible &&
|
|
187
191
|
expandedItem != null &&
|
|
@@ -190,7 +194,7 @@ function DocSidebarItemCategoryCollapsible({
|
|
|
190
194
|
) {
|
|
191
195
|
setCollapsed(true);
|
|
192
196
|
}
|
|
193
|
-
}
|
|
197
|
+
}
|
|
194
198
|
const handleItemClick = (e) => {
|
|
195
199
|
onItemClick?.(item);
|
|
196
200
|
if (collapsible) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, {
|
|
7
|
+
import React, {useState} from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import {
|
|
10
10
|
isRegexpStringMatch,
|
|
@@ -61,11 +61,14 @@ function useItemCollapsible({active}) {
|
|
|
61
61
|
initialState: () => !active,
|
|
62
62
|
});
|
|
63
63
|
// Expand if any item active after a navigation
|
|
64
|
-
|
|
64
|
+
// See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
65
|
+
const [wasActive, setWasActive] = useState(active);
|
|
66
|
+
if (active !== wasActive) {
|
|
67
|
+
setWasActive(active);
|
|
65
68
|
if (active) {
|
|
66
69
|
setCollapsed(false);
|
|
67
70
|
}
|
|
68
|
-
}
|
|
71
|
+
}
|
|
69
72
|
return {
|
|
70
73
|
collapsed,
|
|
71
74
|
toggleCollapsed,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "4.0.0-canary-
|
|
3
|
+
"version": "4.0.0-canary-6835",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "4.0.0-canary-
|
|
24
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
25
|
-
"@docusaurus/mdx-loader": "4.0.0-canary-
|
|
26
|
-
"@docusaurus/module-type-aliases": "4.0.0-canary-
|
|
27
|
-
"@docusaurus/plugin-content-blog": "4.0.0-canary-
|
|
28
|
-
"@docusaurus/plugin-content-docs": "4.0.0-canary-
|
|
29
|
-
"@docusaurus/plugin-content-pages": "4.0.0-canary-
|
|
30
|
-
"@docusaurus/theme-common": "4.0.0-canary-
|
|
31
|
-
"@docusaurus/theme-translations": "4.0.0-canary-
|
|
32
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
33
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
34
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
35
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
23
|
+
"@docusaurus/core": "4.0.0-canary-6835",
|
|
24
|
+
"@docusaurus/logger": "4.0.0-canary-6835",
|
|
25
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6835",
|
|
26
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6835",
|
|
27
|
+
"@docusaurus/plugin-content-blog": "4.0.0-canary-6835",
|
|
28
|
+
"@docusaurus/plugin-content-docs": "4.0.0-canary-6835",
|
|
29
|
+
"@docusaurus/plugin-content-pages": "4.0.0-canary-6835",
|
|
30
|
+
"@docusaurus/theme-common": "4.0.0-canary-6835",
|
|
31
|
+
"@docusaurus/theme-translations": "4.0.0-canary-6835",
|
|
32
|
+
"@docusaurus/types": "4.0.0-canary-6835",
|
|
33
|
+
"@docusaurus/utils": "4.0.0-canary-6835",
|
|
34
|
+
"@docusaurus/utils-common": "4.0.0-canary-6835",
|
|
35
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6835",
|
|
36
36
|
"@mdx-js/react": "^3.1.1",
|
|
37
37
|
"clsx": "^2.1.1",
|
|
38
38
|
"copy-text-to-clipboard": "^3.2.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=24.21"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "545ee70227b7e3446e96056b3c5e7796711e42b4"
|
|
64
64
|
}
|
|
@@ -10,6 +10,7 @@ import React, {
|
|
|
10
10
|
type ReactNode,
|
|
11
11
|
useEffect,
|
|
12
12
|
useMemo,
|
|
13
|
+
useState,
|
|
13
14
|
} from 'react';
|
|
14
15
|
import clsx from 'clsx';
|
|
15
16
|
import {
|
|
@@ -221,7 +222,12 @@ function DocSidebarItemCategoryCollapsible({
|
|
|
221
222
|
updateCollapsed,
|
|
222
223
|
activePath,
|
|
223
224
|
});
|
|
224
|
-
|
|
225
|
+
|
|
226
|
+
// Collapse when a sibling category gets expanded
|
|
227
|
+
// See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
228
|
+
const [prevExpandedItem, setPrevExpandedItem] = useState(expandedItem);
|
|
229
|
+
if (expandedItem !== prevExpandedItem) {
|
|
230
|
+
setPrevExpandedItem(expandedItem);
|
|
225
231
|
if (
|
|
226
232
|
collapsible &&
|
|
227
233
|
expandedItem != null &&
|
|
@@ -230,7 +236,7 @@ function DocSidebarItemCategoryCollapsible({
|
|
|
230
236
|
) {
|
|
231
237
|
setCollapsed(true);
|
|
232
238
|
}
|
|
233
|
-
}
|
|
239
|
+
}
|
|
234
240
|
|
|
235
241
|
const handleItemClick: ComponentProps<'a'>['onClick'] = (e) => {
|
|
236
242
|
onItemClick?.(item);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React, {
|
|
8
|
+
import React, {useState, type ReactNode, type ComponentProps} from 'react';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import {
|
|
11
11
|
isRegexpStringMatch,
|
|
@@ -80,11 +80,14 @@ function useItemCollapsible({active}: {active: boolean}) {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
// Expand if any item active after a navigation
|
|
83
|
-
|
|
83
|
+
// See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
84
|
+
const [wasActive, setWasActive] = useState(active);
|
|
85
|
+
if (active !== wasActive) {
|
|
86
|
+
setWasActive(active);
|
|
84
87
|
if (active) {
|
|
85
88
|
setCollapsed(false);
|
|
86
89
|
}
|
|
87
|
-
}
|
|
90
|
+
}
|
|
88
91
|
|
|
89
92
|
return {
|
|
90
93
|
collapsed,
|