-
Notifications
You must be signed in to change notification settings - Fork 21
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
use of dialog tag for modal structure ? #49
Comments
The tricky part with React is that is not a thing to let a DOM node (a component) to live here, being hidden. But we need to fire the JS's showModal() function to enjoy the properties. I found a little trick (I don't know how many rules it violates but..) to allow to display the modal with something like a boolean useState variable (isOpen) and fire the showModal() function: with 2 async functions and an awaited operation into.
|
I think you have here all the valuable parts of my researchs, as the others (custom hook, portal, ...) are way better on your side. If you want to give it a try, I'ld be happy! |
Hello @dc7290! I hope you are fine, Following our discussion around my POC PR, I was concerned about your question: "For now, I have a feeling that the inconvenience of applying styles when using the dialog element may be a disadvantage.", An elegant answer can be found in the :modal CSS pseudo class that makes styling convenient from outside of the component. It actually has some support, that you can take in consideration. Have a nice day, |
I put here the discussion and ideas instead of in a pull request: Hello @dc7290 , Wonderfull! I will be the first user and fan of this new version!
Beyond that, I can only give advices/wishes about the global API, what can be enjoyable to use. Few ideasHook's APIAs there is non-modal dialog elements and modal ones, I think we need to provide 2 custom hooks, where names must be choose :
I feel like this kind of pattern is a bit annoying and can be optimized:
I wanted to do such a thing:
But it seems that the 'MyModalContent' must output somewhere it can be rendered, and I can't in a hook. Maybe with a global DialogContext? Styling the modalFor the style, I think the easiest way to apply is:
example of style injection:
But it works because I use CSS modules, with nextJS. Maybe this something to try? |
About the usability of tag on browsersI did some tests with my browserstack (stayed on Laptop MacOS):
As you said the main concern is the cutting-edge Safari version for users. As the focus trap, isolation, centering, keyboard are managed, I feel like Here's a good article about how to build around dialog. |
@Nayte91 At least I made something that works, so I'm sharing!
I'm able to solve a lot of problems I was having using the DIALOG element.
|
Hello @dc7290, It works well! I like how it seems simple to use. Also the style's injection seems sweet. I wonder if bodyscrolllock still relevant, as if you choose between ModalDialog (JS showModal()) or NonModalDialog (JS show()) it will define this behavior? Anyway It's a great draft, and I'm impressed how fast you made it! |
Thanks for looking!
Indeed!!! |
@Nayte91 |
Hello! Just wanted to share with you this video from a famous frontend Youtuber who speak about . I'm happy that we are some months before him :) Fortunately there is some nice tricks, especially about how to add a parameter to close the modal dialog when clicking outside. Can be a neat implementation! |
@Nayte91 I see! I am curious about its implementation. |
Hello! I'm really fine, I hope you are too! I actively use the lib and the new modal on my NextJS project :) Noneless I will try this one in june ;) I have the target code, I may succeed in it. I'll keep you in touch ! Waiting for Street Fighter 6 release, launching an app for this occasion, then I will have some time to dive into this. |
Hello,
To begin with, thank you very much for your work on this hook. I'm going mad with react and the absurd difficulty of doing a simple HTML modal, I tried to do my component, and spent a lot of time on tutorials and repositories; For now, I may say that yours is by far the most satisfying out there.. Or at least the one my own style is the most aligned with :)
As my journey begun with the new tag - its new behavior - I was wondering if you already considered your Modal component around this tag ?
If not, let me give you some materials:
On a structure like yours, the dialog tag use can saves you both
<div style={wrapperStyle}>
and<div style={overlayStyle} />
, quite interesting.The text was updated successfully, but these errors were encountered: