Skip to content

Commit

Permalink
fixed issue with an open modal window (#848)
Browse files Browse the repository at this point in the history
Co-authored-by: ost-ptk <[email protected]>
Co-authored-by: Vynnyk Dmytro <[email protected]>
  • Loading branch information
3 people authored Nov 16, 2023
1 parent d85a272 commit fb092aa
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
7 changes: 5 additions & 2 deletions src/libs/ui/components/account-list/account-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const ButtonContainer = styled(CenteredFlexRow)`
`;

interface AccountListProps {
closeModal: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
closeModal: (e: React.MouseEvent) => void;
}

export const AccountList = ({ closeModal }: AccountListProps) => {
Expand Down Expand Up @@ -143,7 +143,10 @@ export const AccountList = ({ closeModal }: AccountListProps) => {
/>
</AccountNameWithHashListItemContainer>
</ListItemClickableContainer>
<AccountActionsMenuPopover account={account} />
<AccountActionsMenuPopover
account={account}
onClick={closeModal}
/>
</AlignedFlexRow>
{isConnected && (
<ConnectionStatusBadgeContainer>
Expand Down
42 changes: 30 additions & 12 deletions src/libs/ui/components/account-popover/account-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import { Account } from '@background/redux/vault/types';

interface AccountActionsMenuPopoverProps {
account: Account;
onClick?: (e: React.MouseEvent) => void;
}
export const AccountActionsMenuPopover = ({
account
account,
onClick
}: AccountActionsMenuPopoverProps) => {
const navigate = useTypedNavigate();
const { t } = useTranslation();
Expand All @@ -40,9 +42,13 @@ export const AccountActionsMenuPopover = ({
{connectedAccountNames.includes(account.name) ? (
<PopoverLink
variant="contentAction"
onClick={e => {
closePopover(e);
onClick={event => {
closePopover(event);
activeOrigin && disconnectAccount(account.name, activeOrigin);

if (onClick) {
onClick(event);
}
}}
>
<SvgIcon
Expand All @@ -57,13 +63,17 @@ export const AccountActionsMenuPopover = ({
) : (
<PopoverLink
variant="contentAction"
onClick={() =>
onClick={event => {
navigate(
isAnyAccountConnected
? `${RouterPath.ConnectAnotherAccount}/${account.name}`
: RouterPath.NoConnectedAccount
)
}
);

if (onClick) {
onClick(event);
}
}}
>
<SvgIcon
src="assets/icons/link.svg"
Expand All @@ -77,11 +87,15 @@ export const AccountActionsMenuPopover = ({
)}
<PopoverLink
variant="contentAction"
onClick={() =>
onClick={event => {
navigate(
RouterPath.RenameAccount.replace(':accountName', account.name)
)
}
);

if (onClick) {
onClick(event);
}
}}
>
<SvgIcon
src="assets/icons/edit.svg"
Expand Down Expand Up @@ -109,11 +123,15 @@ export const AccountActionsMenuPopover = ({
</PopoverLink>
<PopoverLink
variant="contentAction"
onClick={() =>
onClick={event => {
navigate(
RouterPath.AccountSettings.replace(':accountName', account.name)
)
}
);

if (onClick) {
onClick(event);
}
}}
>
<SvgIcon
src="assets/icons/settings.svg"
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ui/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface RenderChildrenProps {
}

interface RenderContentProps {
closeModal: (e: MouseEvent<HTMLDivElement>) => void;
closeModal: (e: MouseEvent) => void;
}

export interface ModalProps extends BaseProps {
Expand All @@ -52,7 +52,7 @@ export const Modal = ({ children, renderContent, placement }: ModalProps) => {
}
});

const closeModal = (e: MouseEvent<HTMLDivElement>) => {
const closeModal = (e: MouseEvent) => {
e.stopPropagation();
setIsOpen(false);
};
Expand Down

0 comments on commit fb092aa

Please sign in to comment.