fix: display back to main navbar menu on mobile even if the navbar is empty

This commit is contained in:
Hossein Mehrabi
2023-06-06 01:21:32 +03:30
parent d2ee08c6c0
commit de64169c7b
4 changed files with 9 additions and 10 deletions
@@ -35,5 +35,6 @@
"devDependencies": {
"@types/fs-extra": "^9.0.13",
"@types/lodash": "^4.14.186"
}
},
"gitHead": "d2ee08c6c0678f78ad70f5d04183f7f781d11563"
}
@@ -30,5 +30,6 @@
},
"devDependencies": {
"@types/lodash": "^4.14.186"
}
},
"gitHead": "d2ee08c6c0678f78ad70f5d04183f7f781d11563"
}
+2 -1
View File
@@ -68,5 +68,6 @@
},
"engines": {
"node": ">=16.14"
}
},
"gitHead": "d2ee08c6c0678f78ad70f5d04183f7f781d11563"
}
@@ -1,9 +1,9 @@
import React from 'react'
import { Typography } from '@acid-info/lsd-react'
import { useThemeConfig } from '@docusaurus/theme-common'
import { useNavbarSecondaryMenu } from '@docusaurus/theme-common/internal'
import Translate from '@docusaurus/Translate'
import { Typography } from '@acid-info/lsd-react'
import { IconArrowLeft } from '@logos-theme/components/Icon'
import React from 'react'
function SecondaryMenuBackButton(props) {
return (
@@ -24,14 +24,10 @@ function SecondaryMenuBackButton(props) {
// The secondary menu slides from the right and shows contextual information
// such as the docs sidebar
export default function NavbarMobileSidebarSecondaryMenu() {
const isPrimaryMenuEmpty = useThemeConfig().navbar.items.length === 0
const secondaryMenu = useNavbarSecondaryMenu()
return (
<>
{/* edge-case: prevent returning to the primaryMenu when it's empty */}
{!isPrimaryMenuEmpty && (
<SecondaryMenuBackButton onClick={() => secondaryMenu.hide()} />
)}
<SecondaryMenuBackButton onClick={() => secondaryMenu.hide()} />
{secondaryMenu.content}
</>
)