Skip to content

Commit

Permalink
fix: added href property to sideNavMenuItem (#16113)
Browse files Browse the repository at this point in the history
* fix: added href property to sideNavMenuItem

* fix: updated snapshots

* chore: update snapshots

---------

Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com>
Co-authored-by: Andrea N. Cardona <cardona.n.andrea@gmail.com>
  • Loading branch information
3 people committed Apr 4, 2024
1 parent 5fc4fb6 commit 4633e13
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Expand Up @@ -7255,6 +7255,9 @@ Map {
"className": Object {
"type": "string",
},
"href": Object {
"type": "string",
},
"isActive": Object {
"type": "bool",
},
Expand Down
24 changes: 22 additions & 2 deletions packages/react/src/components/UIShell/SideNavMenuItem.tsx
Expand Up @@ -29,12 +29,23 @@ interface SideNavMenuItemProps extends HTMLAttributes<HTMLElement> {
* `aria-current="page"`, as well.
*/
isActive?: boolean;

/**
* Optionally provide an href for the underlying li`
*/
href?: string;
}

const SideNavMenuItem = React.forwardRef<HTMLElement, SideNavMenuItemProps>(
function SideNavMenuItem(props, ref: ForwardedRef<HTMLElement>) {
const prefix = usePrefix();
const { children, className: customClassName, isActive, ...rest } = props;
const {
children,
className: customClassName,
isActive,
href,
...rest
} = props;
const className = cx(`${prefix}--side-nav__menu-item`, customClassName);
const linkClassName = cx({
[`${prefix}--side-nav__link`]: true,
Expand All @@ -43,7 +54,11 @@ const SideNavMenuItem = React.forwardRef<HTMLElement, SideNavMenuItemProps>(

return (
<li className={className}>
<Link {...rest} className={linkClassName} ref={ref as Ref<ElementType>}>
<Link
href={href}
{...rest}
className={linkClassName}
ref={ref as Ref<ElementType>}>
<SideNavLinkText>{children}</SideNavLinkText>
</Link>
</li>
Expand All @@ -63,6 +78,11 @@ SideNavMenuItem.propTypes = {
*/
className: PropTypes.string,

/**
* Optionally provide an href for the underlying li`
*/
href: PropTypes.string,

/**
* Optionally specify whether the link is "active". An active link is one that
* has an href that is the same as the current page. Can also pass in
Expand Down

0 comments on commit 4633e13

Please sign in to comment.