fix: show secondary menu if even there is no main one (#5262)

This commit is contained in:
Alexey Pyltsyn 2021-08-02 12:16:32 +03:00 committed by GitHub
parent 650f989dbb
commit 8a198ef20a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@ import {
import useHideableNavbar from '@theme/hooks/useHideableNavbar'; import useHideableNavbar from '@theme/hooks/useHideableNavbar';
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll'; import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
import useWindowSize from '@theme/hooks/useWindowSize'; import useWindowSize from '@theme/hooks/useWindowSize';
import {useActivePlugin} from '@theme/hooks/useDocs';
import NavbarItem, {Props as NavbarItemConfig} from '@theme/NavbarItem'; import NavbarItem, {Props as NavbarItemConfig} from '@theme/NavbarItem';
import Logo from '@theme/Logo'; import Logo from '@theme/Logo';
import IconMenu from '@theme/IconMenu'; import IconMenu from '@theme/IconMenu';
@ -175,16 +176,18 @@ function NavbarMobileSidebar({
</div> </div>
<div className="navbar-sidebar__item navbar-sidebar__item--secondary menu"> <div className="navbar-sidebar__item navbar-sidebar__item--secondary menu">
<button {items.length > 0 && (
type="button" <button
className="clean-btn navbar-sidebar__back" type="button"
onClick={secondaryMenu.hide}> className="clean-btn navbar-sidebar__back"
<Translate onClick={secondaryMenu.hide}>
id="theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel" <Translate
description="The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)"> id="theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel"
Back to main menu description="The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)">
</Translate> Back to main menu
</button> </Translate>
</button>
)}
{secondaryMenu.content} {secondaryMenu.content}
</div> </div>
</div> </div>
@ -199,7 +202,7 @@ function Navbar(): JSX.Element {
const mobileSidebar = useMobileSidebar(); const mobileSidebar = useMobileSidebar();
const colorModeToggle = useColorModeToggle(); const colorModeToggle = useColorModeToggle();
const activeDocPlugin = useActivePlugin();
const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll); const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
const items = useNavbarItems(); const items = useNavbarItems();
@ -218,7 +221,7 @@ function Navbar(): JSX.Element {
})}> })}>
<div className="navbar__inner"> <div className="navbar__inner">
<div className="navbar__items"> <div className="navbar__items">
{items?.length > 0 && ( {(items?.length > 0 || activeDocPlugin) && (
<button <button
aria-label="Navigation bar toggle" aria-label="Navigation bar toggle"
className="navbar__toggle clean-btn" className="navbar__toggle clean-btn"