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] Use html dialog element #485

Open
israelKusayev opened this issue May 15, 2022 · 6 comments
Open

[dialog] Use html dialog element #485

israelKusayev opened this issue May 15, 2022 · 6 comments
Labels
component: dialog This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature

Comments

@israelKusayev
Copy link

israelKusayev commented May 15, 2022

Summary 💡

Since dialog element is supported across all browsers maybe it's time to refactor dialog to use the native <dialog/> tag?

Examples 🌈

👀

Motivation 🔦

https://caniuse.com/dialog

Search keywords:

@israelKusayev israelKusayev added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 15, 2022
@ZeeshanTamboli ZeeshanTamboli added support: question Community support but can be turned into an improvement and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 16, 2022
@ZeeshanTamboli ZeeshanTamboli changed the title use html dialog element [Dialog] Use html dialog element May 16, 2022
@ZeeshanTamboli
Copy link
Member

Not sure, I think global usage also matters. We need to wait for atleast 90% global usage. Currently it is 82.98%.

@PinkaminaDianePie
Copy link

What about now? 93%+ as of today.

@ZeeshanTamboli ZeeshanTamboli reopened this May 6, 2023
@ZeeshanTamboli ZeeshanTamboli added new feature New feature or request waiting for 👍 Waiting for upvotes component: dialog This is the name of the generic UI component, not the React module! and removed support: question Community support but can be turned into an improvement labels May 6, 2023
@kosciolek
Copy link

As of today it's 94.18%

I'm willing to implement this myself, are there any blockers/issues?

@oliviertassinari oliviertassinari transferred this issue from mui/material-ui Jul 21, 2024
@oliviertassinari
Copy link
Member

We looked into this for #372. However, it looks to me that the <dialog> native primitive is not usable, not for a general purpose component design system.

The issues that seems to have no user land solutions, so deal breakers:

  1. I can't find content on nesting modal <dialog>. It's an important use case in my experience for a library like Base UI A popover on top of a modal dialog should be interactable whatwg/html#9936.
  2. I can't find content on how to not make some part of the UI inert when a modal is open, for example, when using Intercom, Drift.com, etc.
  3. From https://2023.stateofhtml.com/en-US/usage/#html_functionality_features data, one data point I found valuable: "auto-focusing the first input works poorly when the first input is typically the 'close' button". Especially on mobile, it messes up the scroll. A bit related to unexpected focus results for tabindex + <dialog>.showModal() whatwg/html#1929. Adam shared this same point in https://youtu.be/XYjH_oQ3llg?si=zR8PgY9jeN8-WXHg&t=4568.
  4. Grammarly browser extension creates its suggestion popup below the <dialog>

@oliviertassinari oliviertassinari added enhancement This is not a bug, nor a new feature and removed new feature New feature or request waiting for 👍 Waiting for upvotes labels Jul 21, 2024
@Link2Twenty
Copy link

Link2Twenty commented Aug 27, 2024

Hi, here are some thoughts

  1. Nesting <dialog> is fine, the most recently opened modal is on top and all other items are inert (including the source modal).
  2. It is possible to move elements that shouldn't be inert into the topmost modal using portals, here's an example
  3. By having a container div inside the modal with tabIndex -1 and outline:none you can force that div to be the focuses on modal open but not selectable with tab, (this is a trick we use a lot).

Related Issues:

@oliviertassinari oliviertassinari changed the title [Dialog] Use html dialog element [dialog] Use html dialog element Sep 2, 2024
@raythurnvoid
Copy link

  1. It is possible to move elements that shouldn't be inert into the topmost modal using portals, here's an example

This should be a no-go, the vendors have to make a change in their API, all that shady code to make something that is very simple (just show something on top of everything else even if it appeared earlier)

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! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

No branches or pull requests

7 participants