Skip to content

Conversation

@salimtb
Copy link
Contributor

@salimtb salimtb commented Sep 23, 2025

Explanation

What is the current state of things and why does it need to change?

The current #onAddNetwork behavior in NetworkEnablementController was inconsistent and didn't provide a good user experience:

  • All newly added networks were automatically enabled, regardless of context
  • The logic for determining "popular networks mode" required ALL popular networks to be enabled, which was impractical
  • Users experienced unexpected network switching when adding popular networks in multi-network scenarios

What is the solution your changes offer and how does it work?

This PR implements a more intuitive network addition behavior:

  1. Improved Popular Networks Detection: Changed from requiring "all popular networks enabled" to ">2 popular networks enabled", making the detection much more practical and user-friendly.

  2. Context-Aware Network Addition:

    • If in popular networks mode (>2 popular networks enabled) AND adding a popular network → Keep current selection (add but don't enable the new network)
    • Otherwise → Switch to the newly added network (disable all others, enable the new one)
  3. Key Benefits:

    • When users have multiple popular networks enabled and add another popular network, their current workflow isn't disrupted
    • When users add non-popular networks or add networks when not in "popular mode", they get the expected behavior of switching to the new network
    • The popular networks threshold (>2) is much more realistic than requiring all popular networks

Are there any changes whose purpose might not obvious to those unfamiliar with the domain?

  • The method rename from #areAllPopularNetworksEnabled() to #isInPopularNetworksMode() reflects the conceptual shift from checking all networks to checking if the user is in a "popular networks" usage pattern
  • The ">2" threshold was chosen because it indicates the user is actively using multiple popular networks (suggesting they prefer the multi-network mode) vs. having just 1-2 networks enabled

References

This change improves the user experience for network management in MetaMask by implementing more intuitive network addition behavior based on user context.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft p

@salimtb salimtb marked this pull request as ready for review September 23, 2025 13:44
@salimtb salimtb requested review from a team as code owners September 23, 2025 13:44
@salimtb salimtb enabled auto-merge (squash) September 23, 2025 14:54
@salimtb salimtb merged commit 7beec79 into main Sep 23, 2025
239 checks passed
@salimtb salimtb deleted the fi/fix-popular-network-case branch September 23, 2025 15:00
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.

3 participants