Commit c9dd38ec authored by tom's avatar tom

fix user profile menu opening/closing

parent af65971f
......@@ -186,7 +186,7 @@ const AuthModal = ({ initialScreen, onClose, mixpanelConfig, closeOnError }: Pro
// we need to allow user interact with element outside of dialog otherwise they can't click on recaptcha
modal={ false }
// FIXME if we allow to close on interact outside, the dialog will be closed when user click on recaptcha
closeOnInteractOutside={ ![ 'email', 'otp_code' ].includes(currentStep.type) }
closeOnInteractOutside={ ![ 'email', 'otp_code', 'connect_wallet', 'select_method' ].includes(currentStep.type) }
trapFocus={ false }
preventScroll={ false }
>
......
......@@ -70,9 +70,13 @@ const UserProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) =>
profileMenu.onClose();
}, [ authModal, profileMenu ]);
const handleProfileMenuOpenChange = React.useCallback(({ open }: { open: boolean }) => {
!open && profileMenu.onOpenChange({ open });
}, [ profileMenu ]);
return (
<>
<PopoverRoot positioning={{ placement: 'bottom-end' }} open={ profileMenu.open } onOpenChange={ profileMenu.onOpenChange }>
<PopoverRoot positioning={{ placement: 'bottom-end' }} open={ profileMenu.open } onOpenChange={ handleProfileMenuOpenChange }>
<PopoverTrigger>
<UserProfileButton
profileQuery={ profileQuery }
......@@ -81,7 +85,7 @@ const UserProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) =>
onClick={ handleProfileButtonClick }
/>
</PopoverTrigger>
{ (profileQuery.data || web3Address) && (
{ (profileQuery.data || web3Address) && profileMenu.open && (
<PopoverContent w="280px">
<PopoverBody>
<UserProfileContent
......
......@@ -64,11 +64,15 @@ const UserProfileMobile = () => {
profileMenu.onClose();
}, [ authModal, profileMenu ]);
const handleProfileMenuOpenChange = React.useCallback(({ open }: { open: boolean }) => {
!open && profileMenu.onOpenChange({ open });
}, [ profileMenu ]);
return (
<>
<DrawerRoot
open={ profileMenu.open }
onOpenChange={ profileMenu.onOpenChange }
onOpenChange={ handleProfileMenuOpenChange }
>
<DrawerBackdrop/>
<DrawerTrigger>
......
......@@ -18,7 +18,7 @@ interface Props {
domain?: string;
}
const UserWalletButton = ({ size, variant, isPending, isAutoConnectDisabled, address, domain }: Props, ref: React.ForwardedRef<HTMLButtonElement>) => {
const UserWalletButton = ({ size, variant, isPending, isAutoConnectDisabled, address, domain, ...rest }: Props, ref: React.ForwardedRef<HTMLButtonElement>) => {
const isMobile = useIsMobile();
......@@ -53,6 +53,7 @@ const UserWalletButton = ({ size, variant, isPending, isAutoConnectDisabled, add
fontWeight={ address ? 700 : 600 }
loading={ isPending }
loadingText={ isMobile ? undefined : 'Connecting' }
{ ...rest }
>
{ content }
</Button>
......
......@@ -61,7 +61,7 @@ const UserWalletDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) => {
isAutoConnectDisabled={ isAutoConnectDisabled }
/>
</PopoverTrigger>
{ web3AccountWithDomain.address && (
{ web3AccountWithDomain.address && walletMenu.open && (
<PopoverContent w="235px">
<PopoverBody>
<UserWalletMenuContent
......
......@@ -59,7 +59,7 @@ const UserWalletMobile = () => {
</DrawerTrigger>
<DrawerContent maxWidth="300px">
<DrawerBody p={ 6 }>
{ web3AccountWithDomain.address && (
{ web3AccountWithDomain.address && walletMenu.open && (
<UserWalletMenuContent
address={ web3AccountWithDomain.address }
domain={ web3AccountWithDomain.domain }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment