Skip to content

Commit

Permalink
OPHJOD-1161: Fix mega menu not closing on mobile when user icon clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikuo committed Jan 7, 2025
1 parent 85db22f commit 283280a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/MegaMenu/MegaMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const MegaMenu = ({ loggedIn, onClose, onLanguageClick, onLogout }: MegaM
<LanguageButton onClick={onLanguageButtonClick} />
</li>
<li className="ml-3">
<UserButton onLogout={onLogout} />
<UserButton onLogout={onLogout} onClick={onClose} />
</li>
</>
)}
Expand Down
8 changes: 7 additions & 1 deletion src/components/UserButton/UserButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { Link, NavLink, useLoaderData } from 'react-router';

interface UserButtonProps {
onLogout: () => void;
onClick?: () => void;
}

export const UserButton = ({ onLogout }: UserButtonProps) => {
export const UserButton = ({ onLogout, onClick }: UserButtonProps) => {
const {
t,
i18n: { language },
Expand Down Expand Up @@ -66,6 +67,11 @@ export const UserButton = ({ onLogout }: UserButtonProps) => {
state={{ callbackURL: ' ' }}
className="flex h-8 w-8 items-center justify-center rounded-full bg-bg-gray-2"
aria-label={t('login')}
onClick={() => {
if (onClick) {
onClick();
}
}}
>
<MdOutlinePerson size={24} />
</Link>
Expand Down

0 comments on commit 283280a

Please sign in to comment.