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: address the issue where account menu remains open on remove profile in extension mode #1532

Merged
merged 1 commit into from
Sep 8, 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
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
Loading