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

[Dialog] Allow to set disableOutsidePointerEvents on DialogContent #2123

Closed
Changes from all commits
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
7 changes: 3 additions & 4 deletions packages/react/dialog/src/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ DialogContent.displayName = CONTENT_NAME;
/* -----------------------------------------------------------------------------------------------*/

type DialogContentTypeElement = DialogContentImplElement;
interface DialogContentTypeProps
extends Omit<DialogContentImplProps, 'trapFocus' | 'disableOutsidePointerEvents'> {}
interface DialogContentTypeProps extends Omit<DialogContentImplProps, 'trapFocus'> {}

const DialogContentModal = React.forwardRef<DialogContentTypeElement, DialogContentTypeProps>(
(props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {
Expand All @@ -264,12 +263,12 @@ const DialogContentModal = React.forwardRef<DialogContentTypeElement, DialogCont

return (
<DialogContentImpl
disableOutsidePointerEvents
{...props}
ref={composedRefs}
// we make sure focus isn't trapped once `DialogContent` has been closed
// (closed !== unmounted when animating out)
trapFocus={context.open}
disableOutsidePointerEvents
onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {
event.preventDefault();
context.triggerRef.current?.focus();
Expand Down Expand Up @@ -303,10 +302,10 @@ const DialogContentNonModal = React.forwardRef<DialogContentTypeElement, DialogC

return (
<DialogContentImpl
disableOutsidePointerEvents={false}
{...props}
ref={forwardedRef}
trapFocus={false}
disableOutsidePointerEvents={false}
onCloseAutoFocus={(event) => {
props.onCloseAutoFocus?.(event);

Expand Down