From 7c481036a08bed3ebf1d9a7bdb425805d6cf833f Mon Sep 17 00:00:00 2001 From: Braian Mellor <braianj@gmail.com> Date: Thu, 21 Nov 2024 13:11:42 -0300 Subject: [PATCH] fix: extra button behaviour in navbar (#566) --- src/components/Navbar/MainMenu/MainMenu.tsx | 1 + src/components/Navbar/MenuItem/MenuItem.tsx | 7 +++++-- src/components/Navbar/MenuItem/MenuItem.types.ts | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Navbar/MainMenu/MainMenu.tsx b/src/components/Navbar/MainMenu/MainMenu.tsx index 4878e474..0fb1c4e4 100644 --- a/src/components/Navbar/MainMenu/MainMenu.tsx +++ b/src/components/Navbar/MainMenu/MainMenu.tsx @@ -75,6 +75,7 @@ export const MainMenu = (props: MainMenuProps) => { mainUrl={extraButton.link} textColor={extraButton.textColor} backgroundColor={extraButton.backgroundColor} + isExtraButton /> ) : null} </div> diff --git a/src/components/Navbar/MenuItem/MenuItem.tsx b/src/components/Navbar/MenuItem/MenuItem.tsx index fcd2f046..c76dfb2c 100644 --- a/src/components/Navbar/MenuItem/MenuItem.tsx +++ b/src/components/Navbar/MenuItem/MenuItem.tsx @@ -16,7 +16,8 @@ export const MenuItem = (props: MenuItemProps) => { isMobile, mainUrl, textColor, - backgroundColor + backgroundColor, + isExtraButton } = props const mainRedirect = useCallback(() => { @@ -27,7 +28,9 @@ export const MenuItem = (props: MenuItemProps) => { <Menu.Item active={activePage === section} onClick={(e: React.MouseEvent) => { - isMobile ? onToggleShowSubMenu(e, true, section) : mainRedirect() + isMobile && !isExtraButton + ? onToggleShowSubMenu(e, true, section) + : mainRedirect() }} onMouseEnter={(e: React.MouseEvent) => !isMobile && onToggleShowSubMenu(e, true, section) diff --git a/src/components/Navbar/MenuItem/MenuItem.types.ts b/src/components/Navbar/MenuItem/MenuItem.types.ts index c6fb39f3..c5b8c6f0 100644 --- a/src/components/Navbar/MenuItem/MenuItem.types.ts +++ b/src/components/Navbar/MenuItem/MenuItem.types.ts @@ -11,6 +11,7 @@ export type MenuItemProps = { ) => void mainUrl?: string isMobile?: boolean + isExtraButton?: boolean textColor?: string backgroundColor?: string }