Skip to content

Commit 09244ff

Browse files
committed
bug: using NavLink for menus
resolves #955
1 parent 668a671 commit 09244ff

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

site/src/components/BorderedMenuRow/BorderedMenuRow.tsx

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface BorderedMenuRowProps {
1717
/** An SvgIcon that will be rendered to the left of the title */
1818
Icon: typeof SvgIcon
1919
/** URL path */
20-
path?: string
20+
path: string
2121
/** Required title of this row */
2222
title: string
2323
/** Defaults to `"wide"` */
@@ -37,38 +37,30 @@ export const BorderedMenuRow: React.FC<BorderedMenuRowProps> = ({
3737
}) => {
3838
const styles = useStyles()
3939

40-
const Component = () => (
41-
<ListItem
42-
classes={{ gutters: styles.rootGutters }}
43-
className={styles.root}
44-
onClick={onClick}
45-
data-status={active ? "active" : "inactive"}
46-
>
47-
<div className={styles.content} data-variant={variant}>
48-
<div className={styles.contentTop}>
49-
<Icon className={styles.icon} />
50-
<Typography className={styles.title}>{title}</Typography>
51-
{active && <CheckIcon className={styles.checkMark} />}
52-
</div>
40+
return (
41+
<NavLink className={styles.link} to={path}>
42+
<ListItem
43+
classes={{ gutters: styles.rootGutters }}
44+
className={styles.root}
45+
data-status={active ? "active" : "inactive"}
46+
onClick={onClick}
47+
>
48+
<div className={styles.content} data-variant={variant}>
49+
<div className={styles.contentTop}>
50+
<Icon className={styles.icon} />
51+
<Typography className={styles.title}>{title}</Typography>
52+
{active && <CheckIcon className={styles.checkMark} />}
53+
</div>
5354

54-
{description && (
55-
<Typography className={styles.description} color="textSecondary" variant="caption">
56-
{ellipsizeText(description)}
57-
</Typography>
58-
)}
59-
</div>
60-
</ListItem>
55+
{description && (
56+
<Typography className={styles.description} color="textSecondary" variant="caption">
57+
{ellipsizeText(description)}
58+
</Typography>
59+
)}
60+
</div>
61+
</ListItem>
62+
</NavLink>
6163
)
62-
63-
if (path) {
64-
return (
65-
<NavLink to={path} className={styles.link}>
66-
<Component />
67-
</NavLink>
68-
)
69-
}
70-
71-
return <Component />
7264
}
7365

7466
const iconSize = 20

0 commit comments

Comments
 (0)