Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extra button behaviour in navbar #566

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/Navbar/MainMenu/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const MainMenu = (props: MainMenuProps) => {
mainUrl={extraButton.link}
textColor={extraButton.textColor}
backgroundColor={extraButton.backgroundColor}
isExtraButton
/>
) : null}
</div>
Expand Down
7 changes: 5 additions & 2 deletions src/components/Navbar/MenuItem/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const MenuItem = (props: MenuItemProps) => {
isMobile,
mainUrl,
textColor,
backgroundColor
backgroundColor,
isExtraButton
} = props

const mainRedirect = useCallback(() => {
Expand All @@ -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
Copy link
Contributor

@kevinszuchet kevinszuchet Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about checking if the onToggleShowSubMenu prop is defined instead of adding a new prop.
Both work for me anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, your option is better. My suggestion won't work

? onToggleShowSubMenu(e, true, section)
: mainRedirect()
}}
onMouseEnter={(e: React.MouseEvent) =>
!isMobile && onToggleShowSubMenu(e, true, section)
Expand Down
1 change: 1 addition & 0 deletions src/components/Navbar/MenuItem/MenuItem.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type MenuItemProps = {
) => void
mainUrl?: string
isMobile?: boolean
isExtraButton?: boolean
textColor?: string
backgroundColor?: string
}
Loading