Skip to content

Commit c79ccbc

Browse files
authored
fix(Tablet): preserve query params when switch tabs (#1254)
1 parent 2be0f0b commit c79ccbc

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

src/containers/Tablet/Tablet.tsx

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ const TABLET_PAGE_TABS = [
6161
const tabletTabSchema = z.nativeEnum(TABLET_TABS_IDS).catch(TABLET_TABS_IDS.history);
6262
const eTypeSchema = z.nativeEnum(EType).or(z.undefined()).catch(undefined);
6363

64+
const tabletQueryParams = {
65+
nodeId: StringParam,
66+
tenantName: StringParam,
67+
type: StringParam,
68+
clusterName: StringParam,
69+
activeTab: StringParam,
70+
};
71+
6472
export function Tablet() {
6573
const dispatch = useTypedDispatch();
6674

@@ -73,12 +81,7 @@ export function Tablet() {
7381
type: queryTabletType,
7482
clusterName: queryClusterName,
7583
},
76-
] = useQueryParams({
77-
nodeId: StringParam,
78-
tenantName: StringParam,
79-
type: StringParam,
80-
clusterName: StringParam,
81-
});
84+
] = useQueryParams(tabletQueryParams);
8285

8386
const [autoRefreshInterval] = useAutoRefreshInterval();
8487
const {currentData, isFetching, error} = tabletApi.useGetTabletQuery(
@@ -181,7 +184,7 @@ function TabletTabs({
181184
hiveId?: string;
182185
history: ITabletPreparedHistoryItem[];
183186
}) {
184-
const [{activeTab}, setParams] = useQueryParams({activeTab: StringParam});
187+
const [{activeTab, ...restParams}, setParams] = useQueryParams(tabletQueryParams);
185188
const isUserAllowedToMakeChanges = useTypedSelector(selectIsUserAllowedToMakeChanges);
186189

187190
const noAdvancedInfo = !isUserAllowedToMakeChanges || !hasHive(hiveId);
@@ -199,21 +202,24 @@ function TabletTabs({
199202

200203
return (
201204
<Flex gap={5} direction="column">
202-
<Tabs
203-
size="l"
204-
items={TABLET_PAGE_TABS.filter(({isAdvanced}) =>
205-
isAdvanced ? !noAdvancedInfo : true,
206-
)}
207-
activeTab={tabletTab}
208-
wrapTo={(tab, tabNode) => {
209-
const path = getTabletPagePath(id, {activeTab: tab.id});
210-
return (
211-
<InternalLink to={path} key={tab.id}>
212-
{tabNode}
213-
</InternalLink>
214-
);
215-
}}
216-
/>
205+
{/* block wrapper fror tabs to preserve height */}
206+
<div>
207+
<Tabs
208+
size="l"
209+
items={TABLET_PAGE_TABS.filter(({isAdvanced}) =>
210+
isAdvanced ? !noAdvancedInfo : true,
211+
)}
212+
activeTab={tabletTab}
213+
wrapTo={(tab, tabNode) => {
214+
const path = getTabletPagePath(id, {...restParams, activeTab: tab.id});
215+
return (
216+
<InternalLink to={path} key={tab.id}>
217+
{tabNode}
218+
</InternalLink>
219+
);
220+
}}
221+
/>
222+
</div>
217223
{tabletTab === 'history' ? <TabletTable history={history} /> : null}
218224
{tabletTab === 'channels' && !noAdvancedInfo ? (
219225
<Channels id={id} hiveId={hiveId} />

0 commit comments

Comments
 (0)