@@ -377,8 +377,12 @@ export class AppKit extends AppKitScaffold {
377377 } ) ;
378378
379379 watchAccount ( wagmiConfig , {
380- onChange : accountData => {
380+ onChange : ( accountData , prevAccountData ) => {
381381 this . syncAccount ( { ...accountData } ) ;
382+
383+ if ( accountData . status === 'disconnected' && prevAccountData . status === 'connected' ) {
384+ this . close ( ) ;
385+ }
382386 }
383387 } ) ;
384388 }
@@ -431,7 +435,7 @@ export class AppKit extends AppKitScaffold {
431435 'address' | 'isConnected' | 'chainId' | 'connector' | 'isConnecting' | 'isReconnecting'
432436 > ) {
433437 this . syncNetwork ( address , chainId , isConnected ) ;
434- this . setLoading ( isConnecting || isReconnecting ) ;
438+ this . setLoading ( ! ! connector && ( isConnecting || isReconnecting ) ) ;
435439
436440 if ( isConnected && address && chainId ) {
437441 const caipAddress : CaipAddress = `${ ConstantsUtil . EIP155 } :${ chainId } :${ address } ` ;
@@ -444,8 +448,7 @@ export class AppKit extends AppKitScaffold {
444448 this . getApprovedCaipNetworksData ( )
445449 ] ) ;
446450 this . hasSyncedConnectedAccount = true ;
447- } else if ( ! isConnected && this . hasSyncedConnectedAccount ) {
448- this . close ( ) ;
451+ } else if ( ! isConnected && ! isConnecting && ! isReconnecting && this . hasSyncedConnectedAccount ) {
449452 this . resetAccount ( ) ;
450453 this . resetWcConnection ( ) ;
451454 this . resetNetwork ( ) ;
@@ -619,7 +622,6 @@ export class AppKit extends AppKitScaffold {
619622
620623 provider . onSetPreferredAccount ( async ( ) => {
621624 await reconnect ( this . wagmiConfig , { connectors : [ connector ] } ) ;
622- this . setLoading ( false ) ;
623625 } ) ;
624626
625627 provider . setOnTimeout ( async ( ) => {
0 commit comments