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 ...@@ -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 // we need to allow user interact with element outside of dialog otherwise they can't click on recaptcha
modal={ false } modal={ false }
// FIXME if we allow to close on interact outside, the dialog will be closed when user click on recaptcha // 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 } trapFocus={ false }
preventScroll={ false } preventScroll={ false }
> >
......
...@@ -70,9 +70,13 @@ const UserProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) => ...@@ -70,9 +70,13 @@ const UserProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) =>
profileMenu.onClose(); profileMenu.onClose();
}, [ authModal, profileMenu ]); }, [ authModal, profileMenu ]);
const handleProfileMenuOpenChange = React.useCallback(({ open }: { open: boolean }) => {
!open && profileMenu.onOpenChange({ open });
}, [ profileMenu ]);
return ( return (
<> <>
<PopoverRoot positioning={{ placement: 'bottom-end' }} open={ profileMenu.open } onOpenChange={ profileMenu.onOpenChange }> <PopoverRoot positioning={{ placement: 'bottom-end' }} open={ profileMenu.open } onOpenChange={ handleProfileMenuOpenChange }>
<PopoverTrigger> <PopoverTrigger>
<UserProfileButton <UserProfileButton
profileQuery={ profileQuery } profileQuery={ profileQuery }
...@@ -81,7 +85,7 @@ const UserProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) => ...@@ -81,7 +85,7 @@ const UserProfileDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) =>
onClick={ handleProfileButtonClick } onClick={ handleProfileButtonClick }
/> />
</PopoverTrigger> </PopoverTrigger>
{ (profileQuery.data || web3Address) && ( { (profileQuery.data || web3Address) && profileMenu.open && (
<PopoverContent w="280px"> <PopoverContent w="280px">
<PopoverBody> <PopoverBody>
<UserProfileContent <UserProfileContent
......
...@@ -64,11 +64,15 @@ const UserProfileMobile = () => { ...@@ -64,11 +64,15 @@ const UserProfileMobile = () => {
profileMenu.onClose(); profileMenu.onClose();
}, [ authModal, profileMenu ]); }, [ authModal, profileMenu ]);
const handleProfileMenuOpenChange = React.useCallback(({ open }: { open: boolean }) => {
!open && profileMenu.onOpenChange({ open });
}, [ profileMenu ]);
return ( return (
<> <>
<DrawerRoot <DrawerRoot
open={ profileMenu.open } open={ profileMenu.open }
onOpenChange={ profileMenu.onOpenChange } onOpenChange={ handleProfileMenuOpenChange }
> >
<DrawerBackdrop/> <DrawerBackdrop/>
<DrawerTrigger> <DrawerTrigger>
......
...@@ -18,7 +18,7 @@ interface Props { ...@@ -18,7 +18,7 @@ interface Props {
domain?: string; 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(); const isMobile = useIsMobile();
...@@ -53,6 +53,7 @@ const UserWalletButton = ({ size, variant, isPending, isAutoConnectDisabled, add ...@@ -53,6 +53,7 @@ const UserWalletButton = ({ size, variant, isPending, isAutoConnectDisabled, add
fontWeight={ address ? 700 : 600 } fontWeight={ address ? 700 : 600 }
loading={ isPending } loading={ isPending }
loadingText={ isMobile ? undefined : 'Connecting' } loadingText={ isMobile ? undefined : 'Connecting' }
{ ...rest }
> >
{ content } { content }
</Button> </Button>
......
...@@ -61,7 +61,7 @@ const UserWalletDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) => { ...@@ -61,7 +61,7 @@ const UserWalletDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) => {
isAutoConnectDisabled={ isAutoConnectDisabled } isAutoConnectDisabled={ isAutoConnectDisabled }
/> />
</PopoverTrigger> </PopoverTrigger>
{ web3AccountWithDomain.address && ( { web3AccountWithDomain.address && walletMenu.open && (
<PopoverContent w="235px"> <PopoverContent w="235px">
<PopoverBody> <PopoverBody>
<UserWalletMenuContent <UserWalletMenuContent
......
...@@ -59,7 +59,7 @@ const UserWalletMobile = () => { ...@@ -59,7 +59,7 @@ const UserWalletMobile = () => {
</DrawerTrigger> </DrawerTrigger>
<DrawerContent maxWidth="300px"> <DrawerContent maxWidth="300px">
<DrawerBody p={ 6 }> <DrawerBody p={ 6 }>
{ web3AccountWithDomain.address && ( { web3AccountWithDomain.address && walletMenu.open && (
<UserWalletMenuContent <UserWalletMenuContent
address={ web3AccountWithDomain.address } address={ web3AccountWithDomain.address }
domain={ web3AccountWithDomain.domain } 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