-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs][Dialog] Add non-modal dialog docs & demo #38684
Conversation
Netlify deploy previewBundle size report |
Sweet, this is a super helpful distinction/demo to be added! Overall, about the docs ⎯ I'd love to hear @samuelsycamore's take on this one ⎯ I think the modal vs. non-modal explanation should probably not be inside a callout. Whenever content gets too big inside of them, I start to feel like they deserve a paragraph on their own. Callouts, to me, sound like extra information. That said, it should probably be inside the "Non-modal" section? Might also be interesting to link the NN Group link for further reference, it's indeed a great resource! All in all, a Material UI docs information hierarchy similar to what we're doing with Base UI would be really beneficial to find these sections quickly! |
Makes total sense, I am on it! |
@danilo-leal I added a cookie banner example too, please check if we want to adjust the styles there! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a few changes, mostly simplifying the copywriting and demos. I think having two demo blocks is a bit overkill 😬 just one seems enough to demonstrate the idea. Also positioned the "Non-modal dialog" content a bit up in the page's hierarchy (not following any specific order, though, but thought that being below "Limitations" was a bit off).
Hope this is ok! It's looking great to me! 😃
Thanks! Let's wait on Sam's final review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have noticed one blocker:
- The rest of the page is not interactive, this is a deal breaker IMHO. This is a modal dialog behavior. I think this would be also true if it was a chatbot.
Otherwise:
- It sets
aria-hidden="true"
on all the elements of the page, this feels wrong. - We want people to click "Allow all", I don't think we can have the least favorable option "Use necessary only" to take the most space on the screen (so the easiest to click). Personally, when I see these banners, I usually click on whatever hides it the fastest. Examples:
- In terms of where the accept button is positioned, I think https://vercel.com/ has the best design. The closest to the footer on mobile and the closest to the center on desktop, it's likely the least effort to click.
- The design has issues on desktop: https://tqptrk.csb.app/
@oliviertassinari Wasn't necessarily looking for the best of the best cookie banner design for this demo 😅 but I tweaked it a bit to be even simpler + fixed the desktop issue there. Also, I just noticed the apparently modal behavior (e.g., can't select text on the page), which we should probably fix as this is a non-modal demo. 😬 |
True, but we can have a great one 😁, these https://tailwindui.com/components/marketing/elements/banners#component-c5bc8a46a1093693fd286f0b74c631f4 aren't bad at all. Speaking of great:
it seems to be an old issue, I can see the same issue on https://v4.mui.com/components/app-bar/#hide-app-bar.
|
I will look into this, in the end it may be best to have a different component instead of modal for the root element if the dialog should be non-modal - we can have this implemented either as prop or a different component. I will start with prop to see how big of a change it would be. |
@mnajdova I suspect that composing Paper, with Fade and TrapFocus is enough for this. No need for Dialog. |
I was testing this a bit, but it's not that straight forward. The TrapFocus does not allow all the functionalities we would need - for e.g. I couldn't set it up to have circular navigation but also allow focusing/taking action by clicking outside of it at the same time. It's not that trivial, maybe we can track the last event and if it is a click outside of it - disable the FocusTrap. I will experiment with this for a bit and report back. I agree it would likely be outside of the scope of the Dialog, but we can likely keep the demo on this page. |
I am converting to draft, I will ask for a review when I have something better. Btw, I had a false self-approval that it works as the demo was iframe so clicking outside of the demo worked as expected 🤦♀️ |
I am happy with the demo now, it's ready for the next round of review. @oliviertassinari you were right about using Fade, TrapFocus and Paper, the tricky part was when to enable/disable the TrapFocus - I've added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oliviertassinari your changes broke the keyboard behavior - the focus is no longer trapped inside the Cookies banner, and one more thing - there are two more focus stops - the TrapFocus's sentinel start and end. For e.g. check how the behavior on https://www.nngroup.com/articles/modal-nonmodal-dialog/ or gmail's email popup is different. From the resources I found, there are the requirements:
|
@mnajdova Ah yes, I wasn't clear. It's what I described with "Enable the trap focus, deferring the cycling issue to #21569." I don't think the root issue is the demo, but the underlying component. |
Aah, I see now, thanks for the clarification. I will look into this issue first, looks like we need to have similar logic to what I had in the demo, unless something else broke it. PR created for fixing the |
f93ee5d
to
f7dba80
Compare
f7dba80
to
aefc6cd
Compare
@samuelsycamore this is ready for final review in terms of copywriting. |
Sorry I missed this before! I'm not sure if anyone else already pointed this out, but the Base UI Modal doc includes this callout:
Maybe we should use the same text here? I suppose the purpose is a little different here, but I like this explanation. |
We have the same callout on the Materia UI's modal page: https://mui.com/material-ui/react-modal/ Did you mean that we should duplicate this on the Dialog page too? |
The end result feel great 👌 |
One of #38630.
In Material UI there is no documentation around non-modal dialogs. The docs states "A Dialog is a type of modal window that appears in front of app content to provide critical information or ask for a decision. Dialogs disable all app functionality when they appear, and remain on screen until confirmed, dismissed, or a required action has been taken.", but there are also non-modal dialogs scenarios, that would be great for us to document to help people build, for e.g. check https://accessuse.eu/en/non-modal-dialogs.html#:~:text=A%20non%2Dmodal%20dialog%20pops,partly%20covered%20by%20the%20dialog. This page has great examples of both use-cases https://www.nngroup.com/articles/modal-nonmodal-dialog/
This PR adds a non-modal section on the dialog page explaining the use-case and how can one build it.
Demo link: https://deploy-preview-38684--material-ui.netlify.app/material-ui/react-dialog/#non-modal-dialog