Skip to content

Commit

Permalink
[Navigation bar] Make the tab clickable
Browse files Browse the repository at this point in the history
The tab was technically clickable but would not trigger the link. The user would have to hit the text to navigate which was not ideal
  • Loading branch information
rikurauhala committed Dec 2, 2024
1 parent 132a21e commit 4c1e116
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => {
const location = useLocation()
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)

const { key, label, path, items } = item
const { key, label, items } = item

const showItem = (subItemKey: string) => {
if (['class', 'completedCoursesSearch', 'overview'].includes(subItemKey)) {
Expand Down Expand Up @@ -93,14 +93,7 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => {
}

return (
<Typography
color="inherit"
component={Link}
data-cy={`nav-bar-button-${key}`}
sx={{ '&:hover': { color: 'inherit' } }}
to={path}
variant="button"
>
<Typography color="inherit" data-cy={`nav-bar-button-${key}`} variant="button">
{label}
</Typography>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppBar, Box, Container, Tab, Tabs, Toolbar } from '@mui/material'
import { useState, useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import { Link, useLocation } from 'react-router-dom'

import { checkUserAccess, getFullStudyProgrammeRights, isDefaultServiceProvider } from '@/common'
import { hasFullAccessToTeacherData } from '@/components/Teachers/util'
Expand Down Expand Up @@ -92,7 +92,13 @@ export const NavigationBar = () => {
{!isLoading && (
<Tabs textColor="inherit" value={activeTab} variant="scrollable">
{Object.entries(visibleNavigationItems).map(([key, item]) => (
<Tab key={key} label={<NavigationButton item={item} />} />
<Tab
component={Link}
key={key}
label={<NavigationButton item={item} />}
sx={{ '&:hover': { color: 'inherit' } }}
to={item.path}
/>
))}
</Tabs>
)}
Expand Down

0 comments on commit 4c1e116

Please sign in to comment.