Skip to content

Commit c120f3a

Browse files
Merge pull request #2238 from Web3Auth/fix/only-metamask-active
fix empty modal when only metamask is active
2 parents b4c36a7 + 6c0db68 commit c120f3a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/modal/src/ui/components/Widget/Widget.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,15 @@ function Widget(props: WidgetProps) {
120120
() => isEmailPasswordLessLoginVisible || isSmsPasswordLessLoginVisible,
121121
[isEmailPasswordLessLoginVisible, isSmsPasswordLessLoginVisible]
122122
);
123-
const showExternalWalletButton = useMemo(() => modalState.hasExternalWallets, [modalState]);
123+
const showExternalWalletButton = useMemo(
124+
() => modalState.hasExternalWallets || !!modalState.externalWalletsConfig[WALLET_CONNECTORS.METAMASK],
125+
[modalState]
126+
);
124127
const showExternalWalletPage = useMemo(
125-
() => (areSocialLoginsVisible || showPasswordLessInput) && !modalState.externalWalletsVisibility,
126-
[areSocialLoginsVisible, showPasswordLessInput, modalState.externalWalletsVisibility]
128+
() =>
129+
(areSocialLoginsVisible || showPasswordLessInput || !!modalState.externalWalletsConfig[WALLET_CONNECTORS.METAMASK]) &&
130+
!modalState.externalWalletsVisibility,
131+
[areSocialLoginsVisible, showPasswordLessInput, modalState]
127132
);
128133

129134
const handleExternalWalletBtnClick = (flag: boolean) => {

packages/modal/src/ui/loginModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,12 @@ export class LoginModal {
297297
options?: { externalWalletsInitialized: boolean; externalWalletsVisibility: boolean; showExternalWalletsOnly: boolean }
298298
): void => {
299299
this.externalWalletsConfig = externalWalletsConfig;
300+
const isMMAvailable = !!externalWalletsConfig[WALLET_CONNECTORS.METAMASK];
300301
this.setState({
301302
externalWalletsConfig,
302303
externalWalletsInitialized: !!options.externalWalletsInitialized,
303304
showExternalWalletsOnly: !!options.showExternalWalletsOnly,
304-
externalWalletsVisibility: !!options.externalWalletsVisibility,
305+
externalWalletsVisibility: isMMAvailable ? false : !!options.externalWalletsVisibility,
305306
});
306307
};
307308

0 commit comments

Comments
 (0)