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] Create new component and hook #372

Draft
wants to merge 63 commits into
base: master
Choose a base branch
from

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented Apr 29, 2024

@michaldudak michaldudak added new feature New feature or request component: dialog This is the name of the generic UI component, not the React module! labels Apr 29, 2024
Comment on lines 68 to 77
if (modal) {
// When the dialog is modal, clicking on the backdrop is recognized as clicking on the dialog itself.
// We need to check whether the click was outside the dialog's bounding box.
// We also don't want to close the dialog when clicking on any descendant of it (such as an open select).
if (
(event.target === popupElement && hasClickedOutsideBoundingBox(event, popupElement)) ||
!popupElement.contains(event.target as Node)
) {
onOpenChange?.(false);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Several issues with "outside click" detection popped up in Floating UI:

  • The dialog shouldn't close if you clicked on the scrollbar if present, since they may be trying to scroll.
  • The contains check needs to handle portaled elements that aren't a direct descendant of the dialog in the DOM and also shadow DOM elements.
  • It shouldn't close if clicking a third-party widget (e.g. extension popup or toast) that appeared up after the dialog was rendered over the top. (This actually may bring about another problem I saw a few months ago - third-party widgets that don't use top-layer elements can't ever appear over the dialog itself? This includes Grammarly popups, translation popups, etc.)
  • "Click outside" should use mousedown not pointerdown since touch events can fire on elements beneath the backdrop with touch input unintentionally otherwise when dimissing.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can solve almost all of these problems with our ClickAwayListener. The only issue that remains is the top-layer thing. I've investigated this for a while, but I don't think we can work around it, unfortunately.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 3, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 8, 2024
@mui-bot
Copy link

mui-bot commented May 14, 2024

Netlify deploy preview

https://deploy-preview-372--base-ui.netlify.app/

Generated by 🚫 dangerJS against 941182f

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 22, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 22, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 22, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 22, 2024
Comment on lines +71 to +73
* Determines whether the dialog should close when clicking outside of it or pressing the escape key.
*/
softClose: SoftCloseOptions;
Copy link
Contributor

Choose a reason for hiding this comment

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

MDN docs call this light dismiss instead. I also think it should be the default if it isn't here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: dialog This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dialog] Implement Dialog
3 participants