Commit 04164a55 authored by vignesh mohankumar's avatar vignesh mohankumar Committed by GitHub

fix: close WalletModal on connection (#4670)

* fix: close WalletModal on connection

* fix test
parent 16a5e150
......@@ -24,6 +24,7 @@ describe('Wallet', () => {
})
it('shows connect buttons after disconnect', () => {
cy.get('[data-testid=web3-status-connected]').contains(TEST_ADDRESS_NEVER_USE_SHORTENED).click()
cy.contains('Disconnect').click()
cy.get('[data-testid=option-grid]').should('exist')
})
......
......@@ -8,6 +8,7 @@ import { AutoColumn } from 'components/Column'
import { AutoRow } from 'components/Row'
import { getConnection, getConnectionName, getIsCoinbaseWallet, getIsInjected, getIsMetaMask } from 'connection/utils'
import { RedesignVariant, useRedesignFlag } from 'featureFlags/flags/redesign'
import usePrevious from 'hooks/usePrevious'
import { useCallback, useEffect, useState } from 'react'
import { ArrowLeft } from 'react-feather'
import { updateConnectionError } from 'state/connection/reducer'
......@@ -149,6 +150,8 @@ export default function WalletModal({
}) {
const dispatch = useAppDispatch()
const { connector, account, chainId } = useWeb3React()
const previousAccount = usePrevious(account)
const [connectedWallets, addWalletToConnectedWallets] = useConnectedWallets()
const redesignFlag = useRedesignFlag()
......@@ -174,6 +177,12 @@ export default function WalletModal({
}
}, [walletModalOpen, setWalletView, account])
useEffect(() => {
if (account && account !== previousAccount && walletModalOpen) {
toggleWalletModal()
}
}, [account, previousAccount, toggleWalletModal, walletModalOpen])
useEffect(() => {
if (pendingConnector && walletView !== WALLET_VIEWS.PENDING) {
updateConnectionError({ connectionType: getConnection(pendingConnector).type, error: undefined })
......
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