Skip to content

Commit

Permalink
fix: added useMatchMedia validation (#14444)
Browse files Browse the repository at this point in the history
Co-authored-by: Taylor Jones <[email protected]>
  • Loading branch information
guidari and tay1orjones authored Aug 17, 2023
1 parent 628c818 commit 5cf417c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react/src/components/UIShell/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { keys, match } from '../../internal/keyboard';
import { useMergedRefs } from '../../internal/useMergedRefs';
import { useWindowEvent } from '../../internal/useEvent';
import { useDelayedState } from '../../internal/useDelayedState';
import { breakpoints } from '@carbon/layout';
import { useMatchMedia } from '../../internal/useMatchMedia';
// TO-DO: comment back in when footer is added for rails
// import SideNavFooter from './SideNavFooter';

Expand Down Expand Up @@ -224,6 +226,9 @@ function SideNavRenderFunction(
}
});

const lgMediaQuery = `(min-width: ${breakpoints.lg.width})`;
const isLg = useMatchMedia(lgMediaQuery);

return (
<SideNavContext.Provider value={{ isRail }}>
{isFixedNav ? null : (
Expand All @@ -234,7 +239,7 @@ function SideNavRenderFunction(
tabIndex={-1}
ref={navRef}
className={`${prefix}--side-nav__navigation ${className}`}
inert={!isRail && (expanded ? undefined : -1)}
inert={!isRail && (expanded || isLg ? undefined : -1)}
{...accessibilityLabel}
{...eventHandlers}
{...other}>
Expand Down

0 comments on commit 5cf417c

Please sign in to comment.