Commit e2385787 authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #260 from blockscout/tabs-query

remove query params from tab navigation
parents 2ac20b59 d1f71efb
......@@ -6,6 +6,7 @@ import {
TabPanels,
} from '@chakra-ui/react';
import type { StyleProps } from '@chakra-ui/styled-system';
import { pick } from 'lodash';
import { useRouter } from 'next/router';
import React, { useEffect, useState } from 'react';
......@@ -16,6 +17,8 @@ import useIsMobile from 'lib/hooks/useIsMobile';
import RoutedTabsMenu from './RoutedTabsMenu';
import useAdaptiveTabs from './useAdaptiveTabs';
const PRESERVED_QUERY = [ 'network_type', 'network_sub_type' ];
const hiddenItemStyles: StyleProps = {
position: 'absolute',
top: '-9999px',
......@@ -49,7 +52,7 @@ const RoutedTabs = ({ tabs }: Props) => {
const handleTabChange = React.useCallback((index: number) => {
const nextTab = tabs[index];
router.query.tab = nextTab.id;
router.query = { ...pick(router.query, PRESERVED_QUERY), tab: nextTab.id };
router.push(router);
}, [ tabs, router ]);
......
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