mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-01 19:27:48 +02:00
Fix bugs (wrong way)
This commit is contained in:
parent
aa997da632
commit
5403817d55
1 changed files with 12 additions and 1 deletions
|
@ -122,6 +122,15 @@ function DocSidebarItemCategory({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// todo: this hook should not be there at all, when re-rendering
|
||||||
|
// (= clearing filter input), the `collapsed` state is not calculated
|
||||||
|
// correctly (if input of `item.collapsed` is `true`, it is `false` here)
|
||||||
|
useEffect(() => {
|
||||||
|
if (filterTerm === '' && !isActive && item.collapsible) {
|
||||||
|
setCollapsed(item.collapsed);
|
||||||
|
}
|
||||||
|
}, [filterTerm, isActive, item.collapsible, setCollapsed, item.collapsed]);
|
||||||
|
|
||||||
useAutoExpandActiveCategory({isActive, collapsed, setCollapsed});
|
useAutoExpandActiveCategory({isActive, collapsed, setCollapsed});
|
||||||
const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
|
const {expandedItem, setExpandedItem} = useDocSidebarItemsExpandedState();
|
||||||
function updateCollapsed(toCollapsed: boolean = !collapsed) {
|
function updateCollapsed(toCollapsed: boolean = !collapsed) {
|
||||||
|
@ -134,7 +143,8 @@ function DocSidebarItemCategory({
|
||||||
collapsible &&
|
collapsible &&
|
||||||
expandedItem &&
|
expandedItem &&
|
||||||
expandedItem !== index &&
|
expandedItem !== index &&
|
||||||
autoCollapseSidebarCategories
|
autoCollapseSidebarCategories &&
|
||||||
|
!filterTerm
|
||||||
) {
|
) {
|
||||||
setCollapsed(true);
|
setCollapsed(true);
|
||||||
}
|
}
|
||||||
|
@ -144,6 +154,7 @@ function DocSidebarItemCategory({
|
||||||
index,
|
index,
|
||||||
setCollapsed,
|
setCollapsed,
|
||||||
autoCollapseSidebarCategories,
|
autoCollapseSidebarCategories,
|
||||||
|
filterTerm,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Reference in a new issue