Skip to content

Commit e71a9d5

Browse files
authored
Merge pull request #1842 from sushi-labs/fix/stake-sidebar-links
fix: sidebar links on /stake
2 parents 423a3d3 + fad26f5 commit e71a9d5

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

apps/web/src/app/(networks)/(evm)/stake/layout.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
2121
selectedNetwork={ChainId.ETHEREUM}
2222
supportedNetworks={supportedNetworks}
2323
shiftContent
24+
onSelect={null}
2425
>
2526
<div className="flex flex-col flex-1 overflow-y-auto">
2627
<Container maxWidth="5xl" className="px-4 pt-16 mb-12">

apps/web/src/ui/sidebar/index.tsx

+15-12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export interface SidebarContainerProps {
7676
connectedNetwork?: number | string
7777
supportedNetworks?: readonly (ChainId | NonStandardChainId)[]
7878
unsupportedNetworkHref?: string
79+
onSelect?: ((network: ChainId | NonStandardChainId) => void) | null
7980
}
8081

8182
export const SidebarContainer: FC<SidebarContainerProps> = ({
@@ -85,6 +86,7 @@ export const SidebarContainer: FC<SidebarContainerProps> = ({
8586
connectedNetwork,
8687
supportedNetworks,
8788
unsupportedNetworkHref,
89+
onSelect,
8890
}) => {
8991
const { isOpen } = useSidebar()
9092

@@ -94,6 +96,7 @@ export const SidebarContainer: FC<SidebarContainerProps> = ({
9496
selectedNetwork={selectedNetwork}
9597
connectedNetwork={connectedNetwork}
9698
supportedNetworks={supportedNetworks}
99+
onSelect={onSelect}
97100
unsupportedNetworkHref={unsupportedNetworkHref}
98101
/>
99102
<div
@@ -113,6 +116,7 @@ const Sidebar: FC<Omit<SidebarContainerProps, 'children' | 'shiftContent'>> = ({
113116
connectedNetwork,
114117
supportedNetworks = SUPPORTED_NETWORKS,
115118
unsupportedNetworkHref,
119+
onSelect: _onSelect,
116120
}) => {
117121
const { isOpen } = useSidebar()
118122

@@ -127,19 +131,18 @@ const Sidebar: FC<Omit<SidebarContainerProps, 'children' | 'shiftContent'>> = ({
127131

128132
const onSelect = useCallback(
129133
(value: string) => {
130-
const network = value.split('__')[1]
131-
132-
push(
133-
replaceNetworkSlug(
134-
isChainId(+network)
135-
? (+network as ChainId)
136-
: (network as NonStandardChainId),
137-
pathname,
138-
),
139-
{ scroll: false },
140-
)
134+
const _network = value.split('__')[1]
135+
136+
const network = isChainId(+_network)
137+
? (+_network as ChainId)
138+
: (_network as NonStandardChainId)
139+
140+
if (_onSelect === null) return
141+
if (typeof _onSelect === 'function') return _onSelect(network)
142+
143+
push(replaceNetworkSlug(network, pathname), { scroll: false })
141144
},
142-
[pathname, push],
145+
[pathname, push, _onSelect],
143146
)
144147

145148
return !isOpen ? null : (

0 commit comments

Comments
 (0)