fix: respect explicit chainStatus on ConnectButton for single-chain dApps#2676
Open
Kropiunig wants to merge 1 commit into
Open
fix: respect explicit chainStatus on ConnectButton for single-chain dApps#2676Kropiunig wants to merge 1 commit into
Kropiunig wants to merge 1 commit into
Conversation
…Apps Previously the chain selector on ConnectButton was hidden whenever exactly one chain was configured, even when the consumer explicitly set the chainStatus prop. This made it impossible to keep the active network visible on the default ConnectButton without dropping down to ConnectButton.Custom. The default behavior is preserved (the selector is still hidden for single-chain dApps that do not pass chainStatus). Passing any value for chainStatus is now treated as an explicit opt-in: the selector renders for 'full', 'icon', or 'name', and stays suppressed via the existing display sprinkle for 'none'. Closes rainbow-me#1418
|
Someone is attempting to deploy a commit to the rainbowdotme Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: df63279 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1418.
The chain selector on
ConnectButtonis currently hidden whenever exactly one chain is configured, even when the consumer explicitly sets thechainStatusprop. The conditional atpackages/rainbowkit/src/components/ConnectButton/ConnectButton.tsx:83gates rendering onchains.length > 1 || unsupportedChain, so settingchainStatus="full"/"icon"/"name"has no effect for single-chain dApps. Authors who want to keep the active network visible have had to drop down toConnectButton.Custom.@DanielSinclair indicated in the issue thread that a prop-based way to always show the chain was the intended fix ("We'll work on a prop to always show the current chain"). Rather than introduce a new prop, this PR treats any explicit value for the existing
chainStatusprop as an opt-in, while keeping the historical default-hide behavior for consumers that do not pass the prop.Changes
packages/rainbowkit/src/components/ConnectButton/ConnectButton.tsx— Make the chain-selector visibility check honor an explicitchainStatus. The prop is read into a localchainStatusProp;chainStatusExplicittracks whether the consumer passed any value, and a new|| chainStatusExplicitbranch is added to the existingchains.length > 1 || unsupportedChainguard. The internalchainStatusvariable now falls back to the existing default when no value is supplied, so all downstreammapResponsiveValue(chainStatus, …)calls behave exactly as before. ThechainStatus="none"escape hatch keeps working through the existingdisplaysprinkle.packages/rainbowkit/src/components/ConnectButton/ConnectButton.test.tsx— Adds a connected-state test suite covering: (1) default hide behavior for single-chain dApps, (2) explicitchainStatus="full"rendering the selector, (3) explicitchainStatus="none"keeping the selector suppressed via thedisplay_nonesprinkle.site/data/en-US/docs/connect-button.mdx— Notes in the existing Chain status section that passing any explicitchainStatusvalue will force the selector to render on single-chain dApps..changeset/connect-button-explicit-chain-status.md— Patch-level changeset for@rainbow-me/rainbowkit.Backwards compatibility
This is a non-breaking change. Consumers that do not pass
chainStatusstill see the existing default behavior (selector hidden on single-chain dApps). The behavior change only activates whenchainStatusis passed explicitly — which today is a no-op for single-chain dApps anyway.Test plan
Per the locale-files note in AGENTS.md, only the
en-USdoc file was updated.