Skip to content

Commit d2e4329

Browse files
committed
automatically show all wallets in main list if total wallets <= 15 and
1 parent 9272c4c commit d2e4329

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ function ConnectWallet(props: ConnectWalletProps) {
126126

127127
const handleChainFilterChange = (chain: string) => {
128128
setSelectedChain(chain);
129-
setIsShowAllWallets(false);
130129
};
131130

132131
const filteredButtons = useMemo(() => {
@@ -153,12 +152,14 @@ function ConnectWallet(props: ConnectWalletProps) {
153152
return walletDiscoverySupported ? defaultButtons.length : installedWalletButtons.length;
154153
}, [walletDiscoverySupported, defaultButtons, installedWalletButtons, isShowAllWallets, totalExternalWalletsCount]);
155154

156-
// Automatically show all wallets if there are less than 15 wallets
155+
// Automatically show all wallets if there are less than or equal to 15 wallets
157156
useEffect(() => {
158-
if (walletDiscoverySupported && !walletSearch && totalExternalWalletsCount > 0 && totalExternalWalletsCount < 15) {
157+
if (walletDiscoverySupported && totalExternalWalletsCount <= 15) {
159158
setIsShowAllWallets(true);
159+
} else {
160+
setIsShowAllWallets(false);
160161
}
161-
}, [walletDiscoverySupported, walletSearch, totalExternalWalletsCount]);
162+
}, [walletDiscoverySupported, totalExternalWalletsCount]);
162163

163164
/**
164165
* Wallet click logic
@@ -296,6 +297,7 @@ function ConnectWallet(props: ConnectWalletProps) {
296297
deviceDetails={deviceDetails}
297298
walletConnectUri={walletConnectUri}
298299
buttonRadius={buttonRadius}
300+
isShowAllWallets={isShowAllWallets}
299301
/>
300302
</div>
301303
)}

packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useState } from "react";
21
import { useTranslation } from "react-i18next";
32

43
import i18n from "../../../localeImport";
@@ -114,15 +113,15 @@ function ConnectWalletList(props: ConnectWalletListProps) {
114113
deviceDetails,
115114
walletConnectUri,
116115
buttonRadius,
116+
isShowAllWallets,
117117
} = props;
118118

119-
const [showMoreWalletsButton, setShowMoreWalletsButton] = useState(true);
120-
121119
const onShowMoreWalletsClick = () => {
122-
setShowMoreWalletsButton(false);
123120
handleMoreWallets();
124121
};
125122

123+
const showMoreWalletsButton = !isShowAllWallets;
124+
126125
return (
127126
<>
128127
<ul
@@ -143,7 +142,7 @@ function ConnectWalletList(props: ConnectWalletListProps) {
143142
/>
144143
)}
145144
</ul>
146-
{showMoreWalletsButton && totalExternalWalletsCount > 15 && !isLoading && initialWalletCount < totalExternalWalletsCount && (
145+
{showMoreWalletsButton && !isLoading && initialWalletCount < totalExternalWalletsCount && (
147146
<MoreWalletsButton
148147
totalExternalWalletsCount={totalExternalWalletsCount}
149148
initialWalletCount={initialWalletCount}

packages/modal/src/ui/components/ConnectWallet/ConnectWalletList/ConnectWalletList.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface ConnectWalletListProps {
1111
buttonRadius: ButtonRadiusType;
1212
handleWalletClick: (button: ExternalButton) => void;
1313
handleMoreWallets: () => void;
14+
isShowAllWallets: boolean;
1415
}
1516

1617
export type WalletsFoundProps = Pick<

0 commit comments

Comments
 (0)