Skip to content

Commit 1fcc7ca

Browse files
fix: Fix tab default (coder#5104)
1 parent e6ead7d commit 1fcc7ca

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

site/src/hooks/useTab.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useSearchParams } from "react-router-dom"
22

33
export interface UseTabResult {
4-
value: string | null
4+
value: string
55
set: (value: string) => void
66
}
77

8-
export const useTab = (tabKey: string): UseTabResult => {
8+
export const useTab = (tabKey: string, defaultValue: string): UseTabResult => {
99
const [searchParams, setSearchParams] = useSearchParams()
10-
const value = searchParams.get(tabKey)
10+
const value = searchParams.get(tabKey) ?? defaultValue
1111

1212
return {
1313
value,

site/src/pages/TemplateVersionPage/TemplateVersionPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const TemplateVersionPage: FC = () => {
2020
const [state] = useMachine(templateVersionMachine, {
2121
context: { versionName, orgId },
2222
})
23-
const tab = useTab("file")
23+
const tab = useTab("file", "0")
2424
const { t } = useTranslation("templateVersionPage")
2525

2626
return (

0 commit comments

Comments
 (0)