Skip to content

fix: ensure 'incorrect wallet' modal can actually close#1483

Open
timothyylim wants to merge 3 commits intomainfrom
tim/exit-connect-wallet-modal
Open

fix: ensure 'incorrect wallet' modal can actually close#1483
timothyylim wants to merge 3 commits intomainfrom
tim/exit-connect-wallet-modal

Conversation

@timothyylim
Copy link
Collaborator

@timothyylim timothyylim commented Oct 17, 2025

@vercel
Copy link
Contributor

vercel bot commented Oct 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
comps Ready Ready Preview Comment Dec 8, 2025 7:02pm
comps-staging2 Ready Ready Preview Comment Dec 8, 2025 7:02pm

@github-actions
Copy link
Contributor

github-actions bot commented Oct 17, 2025

📊 Test Coverage Report

Package Lines Statements Functions Branches
apps/api 2.91% 2.91% 43.28% 53.11%
apps/comps 0.33% 0.33% 42.04% 44.44%
packages/conversions 100.00% 100.00% 100.00% 100.00%
packages/db 1.79% 1.79% 22.10% 34.44%
packages/rewards 100.00% 100.00% 100.00% 100.00%
packages/services 51.16% 51.16% 67.32% 79.28%
packages/staking-contracts 100.00% 100.00% 100.00% 100.00%

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR aims to fix the inability to close the "incorrect wallet" modal by introducing a dismissal mechanism and resetting it when connected wallets change.

  • Track user dismissal via a new state flag to prevent the modal from re-opening immediately.
  • Reset the dismissal flag when the set of connected wallet addresses changes.
  • Adjust the modal close handler to mark dismissals on close.

Comment on lines 116 to +131
const handleCloseWrongWalletModal = useCallback(
(open: boolean) => {
disconnect(undefined, {
onSuccess: () => setIsWrongWalletModalOpen(open),
onSuccess: () => {
setIsWrongWalletModalOpen(open);

// When closing, explicitly mark that the user has dismissed the warning
if (!open) {
setUserDismissedWrongWallet(true);
}
},
});
},
[setIsWrongWalletModalOpen, disconnect],
[disconnect],
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disconnect is invoked unconditionally, which will also run when open is true (e.g., if used as a Dialog onOpenChange handler). This can unintentionally disconnect when the modal opens. Guard so disconnect only runs on close, and set the open state immediately when open is true.

Copilot uses AI. Check for mistakes.
Comment on lines 120 to 129
disconnect(undefined, {
onSuccess: () => setIsWrongWalletModalOpen(open),
onSuccess: () => {
setIsWrongWalletModalOpen(open);

// When closing, explicitly mark that the user has dismissed the warning
if (!open) {
setUserDismissedWrongWallet(true);
}
},
});
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing the modal and setting the dismissal flag are gated behind onSuccess; if disconnect fails, the modal cannot close and the dismissal flag never sets. Use onSettled (or also handle onError) to perform state updates regardless of disconnect outcome, or optimistically set the state before calling disconnect.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants