forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Tab doesn't represent the page you are on for non-data asset pages
- Loading branch information
1 parent
0ea6145
commit 0c42436
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
datahub-web-react/src/app/shared/BrowserTabTitleContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { createContext, ReactNode, useContext } from 'react'; | ||
|
||
interface BrowserTitleContextProps { | ||
title: string; | ||
updateTitle: (newTitle: string) => void; | ||
} | ||
|
||
const BrowserTitleContext = createContext<BrowserTitleContextProps | undefined>(undefined); | ||
|
||
export const BrowserTitleProvider: React.FC<{ children: ReactNode }> = ({ children }) => { | ||
const [title, setTitle] = React.useState<string>(''); | ||
|
||
const updateTitle = (newTitle: string) => { | ||
setTitle(newTitle); | ||
}; | ||
|
||
return ( | ||
<BrowserTitleContext.Provider value={{ title, updateTitle }}> | ||
{children} | ||
</BrowserTitleContext.Provider> | ||
); | ||
}; | ||
|
||
export const useBrowserTitle = () => { | ||
const context = useContext(BrowserTitleContext); | ||
if (!context) { | ||
throw new Error('useBrowserTitle must be used within a BrowserTitleProvider'); | ||
} | ||
return context; | ||
}; |