diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 55e8bd39..370bcb0b 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -43,9 +43,10 @@ const MainLayout: React.FunctionComponent = ({ }; }, []); - const toggelPanelContents = () => { + const stylePanelOnExpand = () => { if (panelContentsRef.current) { if (panelContentsRef.current.style.maxHeight === '0px') { + // Scroll height + marginBlockEnd of 16 panelContentsRef.current.style.maxHeight = panelContentsRef.current.scrollHeight + 16 + 'px'; panelContentsRef.current.style.overflow = 'none'; @@ -57,6 +58,13 @@ const MainLayout: React.FunctionComponent = ({ } }; + const stylePanelOnLink = () => { + if (window.innerWidth <= 768) { + panelContentsRef.current.style.maxHeight = '0px'; + panelContentsRef.current.style.overflow = 'hidden'; + } + }; + const oldPathSyntaxMatch = router.asPath.match(/(\?wgsl=[01])#(\S+)/); if (oldPathSyntaxMatch) { const slug = oldPathSyntaxMatch[2]; @@ -84,8 +92,7 @@ const MainLayout: React.FunctionComponent = ({
{ - //setListExpanded(!listExpanded); - toggelPanelContents(); + stylePanelOnExpand(); }} >
@@ -112,7 +119,7 @@ const MainLayout: React.FunctionComponent = ({ { - toggelPanelContents(); + stylePanelOnLink(); }} > {slug}