Commit df554564 authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

fix: chrome tie sort resolution (#6833)

parent f290787b
...@@ -61,13 +61,22 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -61,13 +61,22 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
const showTestnets = useAtomValue(showTestnetsAtom) const showTestnets = useAtomValue(showTestnetsAtom)
const walletSupportsChain = useWalletSupportedChains() const walletSupportsChain = useWalletSupportedChains()
const chains = useMemo( const [supportedChains, unsupportedChains] = useMemo(() => {
() => const { supported, unsupported } = NETWORK_SELECTOR_CHAINS.filter(
NETWORK_SELECTOR_CHAINS.filter((chain) => showTestnets || !TESTNET_CHAIN_IDS.has(chain)).sort((a) => (chain) => showTestnets || !TESTNET_CHAIN_IDS.has(chain)
walletSupportsChain.includes(a) ? -1 : 1 ).reduce(
), (acc, chain) => {
[showTestnets, walletSupportsChain] if (walletSupportsChain.includes(chain)) {
acc.supported.push(chain)
} else {
acc.unsupported.push(chain)
}
return acc
},
{ supported: [], unsupported: [] } as Record<string, SupportedChainId[]>
) )
return [supported, unsupported]
}, [showTestnets, walletSupportsChain])
const ref = useRef<HTMLDivElement>(null) const ref = useRef<HTMLDivElement>(null)
const modalRef = useRef<HTMLDivElement>(null) const modalRef = useRef<HTMLDivElement>(null)
...@@ -99,7 +108,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -99,7 +108,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
const dropdown = ( const dropdown = (
<NavDropdown top="56" left={leftAlign ? '0' : 'auto'} right={leftAlign ? 'auto' : '0'} ref={modalRef}> <NavDropdown top="56" left={leftAlign ? '0' : 'auto'} right={leftAlign ? 'auto' : '0'} ref={modalRef}>
<Column paddingX="8" data-testid="chain-selector-options"> <Column paddingX="8" data-testid="chain-selector-options">
{chains.map((selectorChain: SupportedChainId) => ( {supportedChains.map((selectorChain) => (
<ChainSelectorRow <ChainSelectorRow
disabled={!walletSupportsChain.includes(selectorChain)} disabled={!walletSupportsChain.includes(selectorChain)}
onSelectChain={onSelectChain} onSelectChain={onSelectChain}
...@@ -108,6 +117,15 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -108,6 +117,15 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
isPending={selectorChain === pendingChainId} isPending={selectorChain === pendingChainId}
/> />
))} ))}
{unsupportedChains.map((selectorChain) => (
<ChainSelectorRow
disabled
onSelectChain={() => undefined}
targetChain={selectorChain}
key={selectorChain}
isPending={false}
/>
))}
</Column> </Column>
</NavDropdown> </NavDropdown>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment