From b56495344ce0f7b05fff386b0e91b5a4c7ed5d55 Mon Sep 17 00:00:00 2001 From: Dylan van Nierop <60508913+DivaniNL@users.noreply.github.com> Date: Fri, 4 Dec 2026 15:22:26 +0100 Subject: [PATCH] feat(GCOM-1616): keep keyboard focus and screen readers inside the open navigation menu --- .changeset/navigation-focus-trap.md | 7 +++++++ .../components/Layout/LayoutDefault.tsx | 11 +++++++++-- .../components/Layout/LayoutNavigation.tsx | 3 ++- .../components/Layout/LayoutDefault.tsx | 11 +++++++++-- .../components/Layout/LayoutNavigation.tsx | 3 ++- .../components/Layout/LayoutDefault.tsx | 11 +++++++++-- .../components/Layout/LayoutNavigation.tsx | 3 ++- 7 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 .changeset/navigation-focus-trap.md diff --git a/.changeset/navigation-focus-trap.md b/.changeset/navigation-focus-trap.md new file mode 100644 index 0000000000..0e838a2150 --- /dev/null +++ b/.changeset/navigation-focus-trap.md @@ -0,0 +1,7 @@ +--- +'@graphcommerce/magento-graphcms': patch +'@graphcommerce/magento-open-source': patch +'@graphcommerce/magento-storyblok': patch +--- + +Keyboard focus and screen readers stay out of the page behind the open `NavigationOverlay`: `LayoutNavigation` gives its navigation `selection` to `LayoutDefault`, and `LayoutDefault` is `inert` while the menu is open. diff --git a/examples/magento-graphcms/components/Layout/LayoutDefault.tsx b/examples/magento-graphcms/components/Layout/LayoutDefault.tsx index e3e380ce0a..14ea41b1d3 100644 --- a/examples/magento-graphcms/components/Layout/LayoutDefault.tsx +++ b/examples/magento-graphcms/components/Layout/LayoutDefault.tsx @@ -1,5 +1,5 @@ import { useScrollOffset } from '@graphcommerce/framer-next-pages' -import { dvh } from '@graphcommerce/framer-utils' +import { dvh, useMotionValueValue } from '@graphcommerce/framer-utils' import { Container, extendableComponent, @@ -8,9 +8,10 @@ import { sxx, useFabSize, } from '@graphcommerce/next-ui' +import type { NavigationPath, UseNavigationSelection } from '@graphcommerce/next-ui' import type { SxProps, Theme } from '@mui/material' import { Box } from '@mui/material' -import { useScroll, useTransform } from 'motion/react' +import { motionValue, useScroll, useTransform } from 'motion/react' export type LayoutDefaultProps = { className?: string @@ -21,6 +22,7 @@ export type LayoutDefaultProps = { cartFab?: React.ReactNode children?: React.ReactNode noSticky?: boolean + selection?: UseNavigationSelection sx?: SxProps } & OwnerState @@ -33,6 +35,8 @@ const { withState } = extendableComponent(false) + export function LayoutDefault(props: LayoutDefaultProps) { const { children, @@ -42,6 +46,7 @@ export function LayoutDefault(props: LayoutDefaultProps) { menuFab, cartFab, noSticky, + selection, className, sx = [], } = props @@ -54,9 +59,11 @@ export function LayoutDefault(props: LayoutDefaultProps) { const classes = withState({ noSticky }) const fabIconSize = useFabSize('responsive') + const inert = useMotionValueValue(selection ?? closedSelection, (s) => s !== false) return ( ({ diff --git a/examples/magento-graphcms/components/Layout/LayoutNavigation.tsx b/examples/magento-graphcms/components/Layout/LayoutNavigation.tsx index 56bcb67633..f36d06d417 100644 --- a/examples/magento-graphcms/components/Layout/LayoutNavigation.tsx +++ b/examples/magento-graphcms/components/Layout/LayoutNavigation.tsx @@ -8,7 +8,7 @@ import { LayoutDefault, type LayoutDefaultProps } from './LayoutDefault' import { MenuOverlay } from './MenuOverlay' export type LayoutNavigationProps = LayoutQuery & - Omit + Omit export function LayoutNavigation(props: LayoutNavigationProps) { const { footer, menu, children, ...uiProps } = props @@ -23,6 +23,7 @@ export function LayoutNavigation(props: LayoutNavigationProps) { } footer={