Skip to content

Commit

Permalink
Move back useFocusTrap
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerJDev committed Sep 9, 2024
1 parent 085c97c commit 4d7eba0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
useRefObjectAsForwardedRef(forwardedRef, dialogRef)
const backdropRef = useRef<HTMLDivElement>(null)

useFocusTrap({
containerRef: dialogRef,
initialFocusRef: initialFocusRef ?? autoFocusedFooterButtonRef,
restoreFocusOnCleanUp: returnFocusRef?.current ? false : true,
returnFocusRef,
})

useOnEscapePress(
(event: KeyboardEvent) => {
onClose('escape')
Expand Down Expand Up @@ -469,13 +476,6 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
}),
)

useFocusTrap({
containerRef: dialogRef,
initialFocusRef: initialFocusRef ?? autoFocusedFooterButtonRef,
restoreFocusOnCleanUp: returnFocusRef?.current ? false : true,
returnFocusRef,
})

return (
<>
<Portal>
Expand Down

0 comments on commit 4d7eba0

Please sign in to comment.