Skip to content

Commit 5cf417c

Browse files
guidaritay1orjones
andauthored
fix: added useMatchMedia validation (#14444)
Co-authored-by: Taylor Jones <tay1orjones@users.noreply.github.com>
1 parent 628c818 commit 5cf417c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/react/src/components/UIShell/SideNav.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { keys, match } from '../../internal/keyboard';
2323
import { useMergedRefs } from '../../internal/useMergedRefs';
2424
import { useWindowEvent } from '../../internal/useEvent';
2525
import { useDelayedState } from '../../internal/useDelayedState';
26+
import { breakpoints } from '@carbon/layout';
27+
import { useMatchMedia } from '../../internal/useMatchMedia';
2628
// TO-DO: comment back in when footer is added for rails
2729
// import SideNavFooter from './SideNavFooter';
2830

@@ -224,6 +226,9 @@ function SideNavRenderFunction(
224226
}
225227
});
226228

229+
const lgMediaQuery = `(min-width: ${breakpoints.lg.width})`;
230+
const isLg = useMatchMedia(lgMediaQuery);
231+
227232
return (
228233
<SideNavContext.Provider value={{ isRail }}>
229234
{isFixedNav ? null : (
@@ -234,7 +239,7 @@ function SideNavRenderFunction(
234239
tabIndex={-1}
235240
ref={navRef}
236241
className={`${prefix}--side-nav__navigation ${className}`}
237-
inert={!isRail && (expanded ? undefined : -1)}
242+
inert={!isRail && (expanded || isLg ? undefined : -1)}
238243
{...accessibilityLabel}
239244
{...eventHandlers}
240245
{...other}>

0 commit comments

Comments
 (0)