Skip to content

Commit

Permalink
[Navigation bar] Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rikurauhala committed Dec 2, 2024
1 parent 4c1e116 commit c26728d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions cypress/e2e/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ describe('Users tests', () => {
})

it("only the mocked user's programmes are visible", () => {
cy.get('[data-cy=nav-bar-button-studyProgramme]').click()
cy.get('[data-cy=nav-bar-button-class]').click()
cy.visit('/populations')
cy.contains('label', 'Study programme')
.siblings()
.within(() => {
Expand Down
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, items } = item
const { label, items } = item

const showItem = (subItemKey: string) => {
if (['class', 'completedCoursesSearch', 'overview'].includes(subItemKey)) {
Expand Down Expand Up @@ -64,7 +64,6 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => {
<>
<Typography
color="inherit"
data-cy={`nav-bar-button-${key}`}
onClick={event => setAnchorEl(event.currentTarget)}
sx={{ display: 'flex' }}
variant="button"
Expand All @@ -77,10 +76,9 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => {
showItem(subItem.key) && (
<MenuItem
component={Link}
data-cy={`nav-bar-button-${subItem.key}`}
key={subItem.path}
onClick={() => setAnchorEl(null)}
selected={location.pathname.includes(subItem.path)}
selected={location.pathname?.includes(subItem.path)}
to={subItem.path}
>
{subItem.label}
Expand All @@ -93,7 +91,7 @@ export const NavigationButton = ({ item }: { item: NavigationItem }) => {
}

return (
<Typography color="inherit" data-cy={`nav-bar-button-${key}`} variant="button">
<Typography color="inherit" variant="button">
{label}
</Typography>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,16 @@ export const NavigationBar = () => {
}}
>
<OodikoneLogo />
{!isLoading && (
{!isLoading && location && (
<Tabs textColor="inherit" value={activeTab} variant="scrollable">
{Object.entries(visibleNavigationItems).map(([key, item]) => (
<Tab
component={Link}
component={item.path ? Link : 'div'}
data-cy={`nav-bar-button-${key}`}
key={key}
label={<NavigationButton item={item} />}
sx={{ '&:hover': { color: 'inherit' } }}
to={item.path}
to={item.path ?? ''}
/>
))}
</Tabs>
Expand Down

0 comments on commit c26728d

Please sign in to comment.