mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
Fix/1298 (#1542)
* fix(modal): focus trap added * chore(navbar): changeset added
This commit is contained in:
parent
7a17256268
commit
57909accde
5
.changeset/blue-days-work.md
Normal file
5
.changeset/blue-days-work.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@nextui-org/navbar": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix #1298 navbar-menu focus trapping fixed
|
||||||
@ -5,7 +5,7 @@ import {AnimatePresence, HTMLMotionProps, motion} from "framer-motion";
|
|||||||
import {mergeProps} from "@react-aria/utils";
|
import {mergeProps} from "@react-aria/utils";
|
||||||
import {ReactElement, useCallback} from "react";
|
import {ReactElement, useCallback} from "react";
|
||||||
import {RemoveScroll} from "react-remove-scroll";
|
import {RemoveScroll} from "react-remove-scroll";
|
||||||
import {Overlay} from "@react-aria/overlays";
|
import {Overlay, DismissButton} from "@react-aria/overlays";
|
||||||
|
|
||||||
import {menuVariants} from "./navbar-menu-transitions";
|
import {menuVariants} from "./navbar-menu-transitions";
|
||||||
import {useNavbarContext} from "./navbar-context";
|
import {useNavbarContext} from "./navbar-context";
|
||||||
@ -27,7 +27,8 @@ const NavbarMenu = forwardRef<"ul", NavbarMenuProps>((props, ref) => {
|
|||||||
const {className, children, portalContainer, motionProps, style, ...otherProps} = props;
|
const {className, children, portalContainer, motionProps, style, ...otherProps} = props;
|
||||||
const domRef = useDOMRef(ref);
|
const domRef = useDOMRef(ref);
|
||||||
|
|
||||||
const {slots, isMenuOpen, height, disableAnimation, classNames} = useNavbarContext();
|
const {slots, isMenuOpen, setIsMenuOpen, height, disableAnimation, classNames} =
|
||||||
|
useNavbarContext();
|
||||||
|
|
||||||
const styles = clsx(classNames?.menu, className);
|
const styles = clsx(classNames?.menu, className);
|
||||||
|
|
||||||
@ -35,7 +36,11 @@ const NavbarMenu = forwardRef<"ul", NavbarMenuProps>((props, ref) => {
|
|||||||
({children}: {children: ReactElement}) => {
|
({children}: {children: ReactElement}) => {
|
||||||
return (
|
return (
|
||||||
<RemoveScroll forwardProps enabled={isMenuOpen} removeScrollBar={false}>
|
<RemoveScroll forwardProps enabled={isMenuOpen} removeScrollBar={false}>
|
||||||
{children}
|
<>
|
||||||
|
<DismissButton onDismiss={() => setIsMenuOpen(false)} />
|
||||||
|
{children}
|
||||||
|
<DismissButton onDismiss={() => setIsMenuOpen(false)} />
|
||||||
|
</>
|
||||||
</RemoveScroll>
|
</RemoveScroll>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user