Skip to content

Commit

Permalink
chore(Modal): remove FloatingFocusManager (#2224)
Browse files Browse the repository at this point in the history
resolves #2215
  • Loading branch information
Barsnes authored Aug 12, 2024
1 parent 23192dd commit 795bbe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-bears-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@digdir/designsystemet-react": patch
---

Modal: remove `FloatingFocusManager`
14 changes: 2 additions & 12 deletions packages/react/src/components/Modal/ModalDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
FloatingFocusManager,
useFloating,
useMergeRefs,
} from '@floating-ui/react';
import { useMergeRefs } from '@floating-ui/react';
import { Slot } from '@radix-ui/react-slot';
import cl from 'clsx/lite';
import type { DialogHTMLAttributes } from 'react';
Expand Down Expand Up @@ -48,7 +44,6 @@ export const ModalDialog = forwardRef<HTMLDialogElement, ModalDialogProps>(

// This local ref is used to make sure the modal works without a ModalRoot
const modalDialogRef = useRef<HTMLDialogElement>(null);
const { context } = useFloating();
const { modalRef, setOpen, setCloseModal } = useContext(ModalContext);
const open = useModalState(modalDialogRef);

Expand Down Expand Up @@ -119,12 +114,7 @@ export const ModalDialog = forwardRef<HTMLDialogElement, ModalDialogProps>(
onCancel={onCancel}
{...rest}
>
{open && (
<FloatingFocusManager context={context}>
{/* biome-ignore lint/complexity/noUselessFragments: Workaround for @radix-ui/react-slot support */}
<>{children}</>
</FloatingFocusManager>
)}
{children}
</Component>
);
},
Expand Down

0 comments on commit 795bbe1

Please sign in to comment.