Skip to content

Commit

Permalink
fix: bug with mobile mini-toc closing (#296)
Browse files Browse the repository at this point in the history
* fix: miniToc close animation, pc-desktop-navigation dropdowns style

---------

Co-authored-by: Ruslan Bagautdinov <bagautdinovrl@yandex-team.ru>
  • Loading branch information
JeikZim and Ruslan Bagautdinov authored Sep 20, 2024
1 parent 8a19220 commit f9e141c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/components/SubNavigation/SubNavigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.15);
background: var(--g-color-base-background);

transition: max-height 300ms 0s;
overflow-y: hidden;

will-change: max-height;
Expand All @@ -70,6 +69,7 @@

&_open {
max-height: 100vh;
transition: max-height 300ms 0s;
}
}
}
Expand Down
25 changes: 1 addition & 24 deletions src/components/SubNavigation/hooks/useMiniTocData.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,18 @@
import {useCallback, useMemo, useState} from 'react';

const useMiniTocData = (
pageTitle: string,
hideMiniToc: boolean,
menuOpen: boolean,
// setVisibility: (event: boolean) => void,
// onMiniTocItemClick?: (event: MouseEvent) => void,
) => {
const useMiniTocData = (pageTitle: string, hideMiniToc: boolean, menuOpen: boolean) => {
const [miniTocOpen, setMiniTocOpen] = useState(false);
const [activeMiniTocTitle, setMiniTocTitle] = useState(pageTitle);

const closeMiniToc = useCallback(() => setMiniTocOpen(false), []);

// const onItemClick = (event: MouseEvent) => {
// if (onMiniTocItemClick) {
// onMiniTocItemClick(event);
// }

// setTimeout(() => {
// setVisibility(false);
// closeMiniToc();
// }, 0);
// };

const onActiveItemTitleChange = (title: string) => setMiniTocTitle(title);

const toggleMiniTocOpen = useCallback(() => {
const newState = !miniTocOpen;

// if (newState) {
// setVisibility(true);
// }

setMiniTocOpen(newState);
}, [miniTocOpen]);
// }, [miniTocOpen, setVisibility]);

const miniTocHandler = useMemo(() => {
if (hideMiniToc || menuOpen) {
Expand All @@ -49,7 +27,6 @@ const useMiniTocData = (
activeMiniTocTitle,
closeMiniToc,
miniTocHandler,
// onItemClick,
onActiveItemTitleChange,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
display: none;

.pc-navigation-item:has(&) {
width: 0;
display: none;
}
}
}

0 comments on commit f9e141c

Please sign in to comment.