aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/components/Header/Header.tsx
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-04-10 09:52:17 +0200
committerGitHub <noreply@github.com>2021-04-10 09:52:17 +0200
commitc71d26d513e4e5e36e6983e05dee4ad28ec664c7 (patch)
tree4c19961c28b7279594decb065870c3921051a7dd /webui/src/components/Header/Header.tsx
parentd09b9d7c5a6cd8d201f2444ff1fb6302325e1651 (diff)
parentf980d9487ed1e764a364d5a1f385a09835276962 (diff)
downloadgit-bug-c71d26d513e4e5e36e6983e05dee4ad28ec664c7.tar.gz
Merge pull request #625 from GlancingMind/upstream-minor-bugfixes
Minor bugfixes
Diffstat (limited to 'webui/src/components/Header/Header.tsx')
-rw-r--r--webui/src/components/Header/Header.tsx21
1 files changed, 8 insertions, 13 deletions
diff --git a/webui/src/components/Header/Header.tsx b/webui/src/components/Header/Header.tsx
index 3064f6e4..63146cc9 100644
--- a/webui/src/components/Header/Header.tsx
+++ b/webui/src/components/Header/Header.tsx
@@ -67,14 +67,14 @@ const DisabledTabWithTooltip = (props: TabProps) => {
function Header() {
const classes = useStyles();
const location = useLocation();
- const [selectedTab, setTab] = React.useState(location.pathname);
- const handleTabClick = (
- event: React.ChangeEvent<{}>,
- newTabValue: string
- ) => {
- setTab(newTabValue);
- };
+ // Prevents error of invalid tab selection in <Tabs>
+ // Will return a valid tab path or false if path is unkown.
+ function highlightTab() {
+ const validTabs = ['/', '/code', '/pulls', '/settings'];
+ const tab = validTabs.find((tabPath) => tabPath === location.pathname);
+ return tab === undefined ? false : tab;
+ }
return (
<>
@@ -92,12 +92,7 @@ function Header() {
</Toolbar>
</AppBar>
<div className={classes.offset} />
- <Tabs
- centered
- value={selectedTab}
- onChange={handleTabClick}
- aria-label="nav tabs"
- >
+ <Tabs centered value={highlightTab()} aria-label="nav tabs">
<DisabledTabWithTooltip label="Code" value="/code" {...a11yProps(1)} />
<Tab label="Bugs" value="/" component={Link} to="/" {...a11yProps(2)} />
<DisabledTabWithTooltip