Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DialogV2: re-set focusTrap when footer content changes #4779

Merged
merged 20 commits into from
Sep 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Wrap header and footer with <Box>
  • Loading branch information
TylerJDev committed Jul 31, 2024
commit 7a6b77fbf5a9db355e57b5a0113e6e745cb004c3
19 changes: 8 additions & 11 deletions packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,12 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
}),
)

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

return (
<>
Expand All @@ -494,11 +491,11 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
{...positionDataAttributes}
sx={sx}
>
{header}
<Box>{header}</Box>
<ScrollableRegion aria-labelledby={dialogLabelId} className="DialogOverflowWrapper">
{body}
</ScrollableRegion>
{footer}
<Box>{footer}</Box>
</StyledDialog>
</Backdrop>
</Portal>
Expand Down
Loading