Skip to content

Commit

Permalink
fix: address the issue where account menu remains open on remove prof…
Browse files Browse the repository at this point in the history
…ile (#1532)

closes #1531
  • Loading branch information
Nick-1979 authored Sep 8, 2024
1 parent 814af86 commit e991fc2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ interface Props {
setDisplayPopup: React.Dispatch<React.SetStateAction<number | undefined>>;
}

const Menus = ({ address, handleClose, setAnchorEl, setDisplayPopup }: {
const Menus = ({ address, handleClose, setDisplayPopup }: {
address: string | undefined,
handleClose: () => void,
setAnchorEl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>,
setDisplayPopup: React.Dispatch<React.SetStateAction<number | undefined>>,
}) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -118,7 +117,7 @@ const Menus = ({ address, handleClose, setAnchorEl, setDisplayPopup }: {
<Divider sx={{ bgcolor: 'divider', height: '1px', my: '6px' }} />
<ProfileMenu
address={address}
setUpperAnchorEl={setAnchorEl}
closeParentMenu={handleClose}
/>
{hasPrivateKey &&
<MenuItem
Expand Down Expand Up @@ -202,7 +201,6 @@ function FullScreenAccountMenu ({ address, baseButton, setDisplayPopup }: Props)
<Menus
address={address}
handleClose={handleClose}
setAnchorEl={setAnchorEl}
setDisplayPopup={setDisplayPopup}
/>
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { updateMeta } from '../../../messaging';

interface Props {
address: string | undefined;
setUpperAnchorEl?: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;
closeParentMenu: () => void;
}

interface InputBoxProps {
Expand Down Expand Up @@ -180,7 +180,7 @@ enum STATUS {
SHOW_REMOVE
}

function ProfileMenu ({ address, setUpperAnchorEl }: Props): React.ReactElement<Props> {
function ProfileMenu ({ address, closeParentMenu }: Props): React.ReactElement<Props> {
const theme = useTheme();
const { t } = useTranslation();
const isExtensionMode = useIsExtensionPopup();
Expand All @@ -196,8 +196,8 @@ function ProfileMenu ({ address, setUpperAnchorEl }: Props): React.ReactElement<
const handleClose = useCallback(() => {
setAnchorEl(null);
setShowName(false);
setUpperAnchorEl && setUpperAnchorEl(null);
}, [setUpperAnchorEl]);
closeParentMenu();
}, [closeParentMenu]);

const onAddClick = useCallback((event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => {
setAnchorEl(event.currentTarget);
Expand Down
1 change: 1 addition & 0 deletions packages/extension-polkagate/src/partials/AccountMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function AccountMenu ({ address, isMenuOpen, noMargin, setShowMenu }: Props): Re
<MenuSeparator />
<ProfileMenu
address={address}
closeParentMenu={closeMenu}
/>
{hasPrivateKey &&
<MenuItem
Expand Down

0 comments on commit e991fc2

Please sign in to comment.