Skip to content

[AlertDialog] Explicit modality #758

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

Merged
merged 1 commit into from
Jul 1, 2021
Merged

Conversation

andy-hook
Copy link
Contributor

Force Modal mode on AlertDialog and prevent dismiss on click outside.

@@ -14,8 +14,10 @@ import type * as Polymorphic from '@radix-ui/react-polymorphic';

const ROOT_NAME = 'AlertDialog';

const AlertDialog: React.FC<React.ComponentProps<typeof DialogPrimitive.Root>> = (props) => (
<DialogPrimitive.Root {...props} />
type AlertDialogProps = Omit<React.ComponentProps<typeof DialogPrimitive.Root>, 'modal'>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I have this right? we want to enforce this opinion on consumers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think so.

@@ -14,8 +14,10 @@ import type * as Polymorphic from '@radix-ui/react-polymorphic';

const ROOT_NAME = 'AlertDialog';

const AlertDialog: React.FC<React.ComponentProps<typeof DialogPrimitive.Root>> = (props) => (
<DialogPrimitive.Root {...props} />
type AlertDialogProps = Omit<React.ComponentProps<typeof DialogPrimitive.Root>, 'modal'>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think so.

@@ -62,6 +64,9 @@ const AlertDialogContent = React.forwardRef((props, forwardedRef) => {
event.preventDefault();
cancelRef.current?.focus({ preventScroll: true });
})}
onPointerDownOutside={composeEventHandlers(contentProps.onPointerDownOutside, (event) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need to prevent the escape keydown one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth rejigging what's exposed from Dialog to facilitate the changes here also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha cool, good to know. I suppose that's still a meaningful user action, as opposed to clicking outside by mistake potentially.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should just hardcode it then and remove it from the types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should just hardcode it then and remove it from the types.

That's fine with me, are we sure consumers won't need access to the handler for a different purpose?

@benoitgrelard benoitgrelard merged commit 3368485 into modality Jul 1, 2021
@benoitgrelard benoitgrelard deleted the modality-alert-dialog branch July 1, 2021 14:55
andy-hook pushed a commit that referenced this pull request Aug 2, 2021
)

* [FocusScope] Update API for modality changes (#698)

* [FocusScope] Update API for modality changes

* Address PR feedback

* PR feedback

* [Dialog] Add support for non-modal dialogs (#699)

* [Dialog] Add support for non-modal dialogs

* PR feedback

* [Dialog] Fix non modal toggle on close (#757)

* [AlertDialog] Explicit modality, prevent pointer dismiss (#758)

* [AlertDialog] Don't compose onPointerDownOutside (#759)

* [AlertDialog] Don't compose onPointerDownOutside

* Code style

* [Popover] Add support for modality (#751)

* [Popover] Add support for modality

* Modality scroll behaviour, default to non modal

* Adjust for focus close in chromatic stories

* Fix toggle when closing non modal

* [Dialog][Popover] Update interact description

* [Popover] Restore `checkForDefaultPrevented` (#764)

* [DropdownMenu][ContextMenu] Add modality support (#768)

* [Menu] Support modality

* [DropdownMenu] Expose modality

* [ContextMenu] Expose modality

* [DropdownMenu] `mouseDown` -> `pointerDown`

* [Menu] disableOutsidePointerEvents only when open

* [DropdownMenu][Popover][Dialog] Apply explicit trigger auto focus (#771)

* Explicit trigger focus

* Simplify handling where possible

* Code style, remove redundant check

* [Popover] Revert `onEscapeKeyDown` default check

* Versions

* [Dialog][Popover][DropdownMenu][ContextMenu] Adjust non-modal auto focus behaviour (#799)

* Adjust non-modal auto focus behaviour

* Code style

* Explicitly handle ref clearing

* Refine ref clearing

* Simplify handler composition in non-modal

* Feedback

* Revert auto focus cancellation

* Improve focus handling readability

* [ContextMenu] Adjust non-modal focus handling

* [ContextMenu][Dialog][DropdownMenu][ContextMenu] Adjust ref naming (#805)

* Adjust ref naming

* [ContextMenu] Move modal condition

Co-authored-by: Andy Hook <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants