-
+
)
}
+export type SubNavProps = {
+ hasShadow?: boolean
+ /**
+ * Allows the SubNav to be used at full width,
+ * removing any internal padding and guttering.
+ */
+ fullWidth?: boolean
+ 'data-testid'?: string
+} & PropsWithChildren
>
+
const _SubNavRoot = memo(({id, children, className, 'data-testid': testId, fullWidth, hasShadow}: SubNavProps) => {
const rootRef = React.useRef(null)
const navRef = React.useRef(null)
@@ -172,12 +153,12 @@ const _SubNavRoot = memo(({id, children, className, 'data-testid': testId, fullW
useFocusTrap({containerRef: overlayRef, restoreFocusOnCleanUp: true, disabled: !isOpenAtNarrow})
useEffect(() => {
- if (isOpenAtNarrow) {
+ if (isOpenAtNarrow && !isLarge) {
document.body.style.overflow = 'hidden'
} else {
document.body.style.overflow = 'auto'
}
- }, [isOpenAtNarrow])
+ }, [isOpenAtNarrow, isLarge])
const activeLink = memoizedChildren.find(child => {
if (isValidElement(child)) {
@@ -570,12 +551,14 @@ function _SubMenu({children, className, variant = 'dropdown', ...props}: SubMenu
context.portalRef.current,
)
} else {
+ const Tag = isLarge ? ThemeProvider : React.Fragment
+
return (
-
+
-
+
)
}
}
diff --git a/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-Mobile-viewport-test-e0f45-en-SubNav-Narrow-Dropdown-Variant-Menu-Open-1-linux.png b/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-Mobile-viewport-test-e0f45-en-SubNav-Narrow-Dropdown-Variant-Menu-Open-1-linux.png
index 1d87fb274..b1a58939d 100644
Binary files a/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-Mobile-viewport-test-e0f45-en-SubNav-Narrow-Dropdown-Variant-Menu-Open-1-linux.png and b/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-Mobile-viewport-test-e0f45-en-SubNav-Narrow-Dropdown-Variant-Menu-Open-1-linux.png differ
diff --git a/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-Mobile-viewport-test-ec549-down-Variant-SubNav-Narrow-Dropdown-Variant-1-linux.png b/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-Mobile-viewport-test-ec549-down-Variant-SubNav-Narrow-Dropdown-Variant-1-linux.png
index 3650594f8..ed5f85b05 100644
Binary files a/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-Mobile-viewport-test-ec549-down-Variant-SubNav-Narrow-Dropdown-Variant-1-linux.png and b/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-Mobile-viewport-test-ec549-down-Variant-SubNav-Narrow-Dropdown-Variant-1-linux.png differ
diff --git a/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-SubNav-Dropdown-Variant-1-linux.png b/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-SubNav-Dropdown-Variant-1-linux.png
index c8f1928b8..af5e5d353 100644
Binary files a/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-SubNav-Dropdown-Variant-1-linux.png and b/packages/react/src/SubNav/SubNav.visual.spec.ts-snapshots/Visual-Comparison-SubNav-SubNav-Dropdown-Variant-1-linux.png differ