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