Skip to content

Commit

Permalink
Fix/1298 (#1542)
Browse files Browse the repository at this point in the history
* fix(modal): focus trap added

* chore(navbar): changeset added
  • Loading branch information
jrgarciadev committed Sep 1, 2023
1 parent 7a17256 commit 57909ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-days-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/navbar": patch
---

Fix #1298 navbar-menu focus trapping fixed
11 changes: 8 additions & 3 deletions packages/components/navbar/src/navbar-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {AnimatePresence, HTMLMotionProps, motion} from "framer-motion";
import {mergeProps} from "@react-aria/utils";
import {ReactElement, useCallback} from "react";
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 {useNavbarContext} from "./navbar-context";
Expand All @@ -27,15 +27,20 @@ const NavbarMenu = forwardRef<"ul", NavbarMenuProps>((props, ref) => {
const {className, children, portalContainer, motionProps, style, ...otherProps} = props;
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 MenuWrapper = useCallback(
({children}: {children: ReactElement}) => {
return (
<RemoveScroll forwardProps enabled={isMenuOpen} removeScrollBar={false}>
{children}
<>
<DismissButton onDismiss={() => setIsMenuOpen(false)} />
{children}
<DismissButton onDismiss={() => setIsMenuOpen(false)} />
</>
</RemoveScroll>
);
},
Expand Down

0 comments on commit 57909ac

Please sign in to comment.