Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/curly-years-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@leafygreen-ui/side-nav': major
---

- Wrap SideNavItem components in `React.useRef`
- Update z-index rules on hover styles for SideNavItem components
16 changes: 11 additions & 5 deletions packages/side-nav/src/SideNavItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const defaultStyle = css`
font-family: Akzidenz, ‘Helvetica Neue’, Helvetica, Arial, sans-serif;
appearance: none;
background: none;
z-index: 0;

&::-moz-focus-inner {
border: 0;
Expand All @@ -48,7 +49,6 @@ const defaultStyle = css`
right: 0;

border-radius: 5px;
z-index: -1;
background-color: transparent;
transform: scale(0.9, 0.7);
transition: all 150ms ease-in-out;
Expand All @@ -58,7 +58,7 @@ const defaultStyle = css`
&:focus {
&:before {
transform: scale(0.95, 0.85);
background-color: ${uiColors.gray.light3};
background-color: ${uiColors.gray.light2};
}
}

Expand All @@ -84,6 +84,10 @@ const activeStyle = css`

&:hover {
color: ${uiColors.green.dark3};

&:before {
background-color: ${uiColors.green.light3};
}
}
`;

Expand All @@ -104,8 +108,9 @@ const focusedStyle = css`
`;

// text content styles

const textStyle = css`
position: relative;
z-index: 1;
font-size: 14px;
font-weight: normal;
text-transform: capitalize;
Expand Down Expand Up @@ -205,7 +210,7 @@ const RootComponentTypes = {
* by this prop. Other additional props will be spread on the anchor element.
*/

function SideNavItem(props: SideNavItemProps) {
const SideNavItem = React.forwardRef((props: SideNavItemProps, forwardRef) => {
const {
active = false,
disabled = false,
Expand Down Expand Up @@ -257,6 +262,7 @@ function SideNavItem(props: SideNavItemProps) {
aria-current={active ? ariaCurrentValue : AriaCurrentValue.Unset}
aria-disabled={disabled}
tabIndex={disabled ? -1 : undefined}
ref={forwardRef}
>
<div
className={cx(textStyle, {
Expand All @@ -269,7 +275,7 @@ function SideNavItem(props: SideNavItemProps) {
</Root>
</li>
);
}
});

SideNavItem.displayName = 'SideNavItem';

Expand Down