Skip to content

Conversation

@fairlighteth
Copy link
Contributor

@fairlighteth fairlighteth commented Nov 20, 2025

Summary

Fixes #6133.

Ensures the token selector’s chain state resets on unmount (so Account → Tokens doesn’t inherit a stale selectedTargetChainId) and removes the LaunchDarkly isBridgingEnabled flag in favor of runtime checks (route + wallet compatibility).

Changes

  1. Removed LaunchDarkly isBridgingEnabled flag
    • BridgingEnabledUpdater now uses isWalletCompatible && isSwapRoute.
    • TradeWidgetForm reads bridging state via useIsBridgingEnabled().
    • Comments updated; LD mocks removed from tests.
  2. Stabilized useCloseTokenSelectWidget callback
    • Reads forceOpen from a ref at call-time to avoid ref churn.
  3. Reset widget state on unmount
    • Added cleanup to call closeTokenSelectWidget({ overrideForceLock: true }), clearing selectTokenWidgetAtom.
  4. Added tests
    • Coverage for referential stability, forceOpen blocking, overrideForceLock bypass, normal close, and fresh state usage.

To Test

  • Account → Tokens chain fix (Tokens page shows balances from a different chain #6133):
    • Open swap page → open sell token selector → switch chain in chain panel → navigate to Account → Tokens without closing.
    • Expect balances follow the app’s network selector (not the last selector chain); changing network selector updates balances; no flicker/reloads.
  • Token selector basics: selecting a token closes the selector and fills the field; repeated open/close yields no console errors; returning to swap shows a clean default state.
  • Bridge chain selection: selector stays open while switching chains (forceOpen), swaps use correct chain after selection, and navigating away/back doesn’t preserve stale bridge chain state.
  • Bridging enablement (flag removal): bridging UI appears for compatible wallets on SWAP routes; does NOT appear for smart contract wallets; does NOT appear for LIMIT routes.
  • Limit/TWAP with forceOpen: selector remains open while forceOpen is active; only unmount resets state; in-flow behavior unchanged.

Background

useSourceChainId read selectedTargetChainId from selectTokenWidgetAtom while the widget was open, so navigating away left a custom target chain that Account → Tokens then used. Resetting on unmount restores the wallet/app network, keeps forceOpen semantics intact, and simplifies bridging enablement by dropping the LD flag.

@vercel
Copy link

vercel bot commented Nov 20, 2025

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

Project Deployment Review Updated (UTC)
cowfi Ready Ready Preview Dec 15, 2025 10:34am
explorer-dev Ready Ready Preview Dec 15, 2025 10:34am
swap-dev Ready Ready Preview Dec 15, 2025 10:34am
widget-configurator Ready Ready Preview Dec 15, 2025 10:34am
2 Skipped Deployments
Project Deployment Review Updated (UTC)
cosmos Ignored Ignored Dec 15, 2025 10:34am
sdk-tools Ignored Ignored Preview Dec 15, 2025 10:34am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 20, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/token-selector-12

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fairlighteth fairlighteth changed the title refactor: 12 - integrate useCloseTokenSelectWidget for improved widget clo… refactor(tokenselector): 12 - integrate useCloseTokenSelectWidget for improved widget clo… Nov 20, 2025
@fairlighteth fairlighteth requested review from a team November 20, 2025 16:03
@fairlighteth fairlighteth marked this pull request as ready for review November 20, 2025 16:03
Copy link
Contributor

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants