radix-ui / primitives

Radix Primitives is an open-source UI component library for building high-quality, accessible design systems and web apps. Maintained by @workos.
https://radix-ui.com/primitives
MIT License
15.52k stars 792 forks source link

Dialog abstraction throws`DialogContent` requires a `DialogTitle` since last update #2986

Open Zerebokep opened 3 months ago

Zerebokep commented 3 months ago

Bug report

Current Behavior

Doing a abstraction with {children} as parameter requires the use of Dialog.Title now, I'm basically using this example: https://www.radix-ui.com/primitives/docs/components/dialog#abstract-the-overlay-and-the-close-button

Expected behavior

No error

Suggested solution

It worked until the last update, so I suggest to remove the error when the component is abstracted.

Zerebokep commented 3 months ago

nvm, I'm dumb.

felipedeboni commented 3 months ago

@Zerebokep I don't think they should ignore this. I have a use case where I need to wrap everything inside an iframe to avoid CSS conflicts with the host site, there's too many different css resets out there or even crazy important rules.

A little explanation:

I understand this an edge case, but at the very least we should have a way to disable such console.errors and warnings given everything works as expected.

mririgoyen commented 2 months ago

We are also now seeing this warning. We have parts of the Dialog abstracted, basically into two components:

Before whatever change went in, no errors were output to the console. Starting recently, we are seeing console errors. I have confirmed several times over that the nesting of Dialog components are correct in our implementation. If I go directly into our "Modal" component and insert a Title there directly, the error goes away. It is definitely the abstraction causing the error, whereas it wasn't previously.


Lucky enough, it seems that this warning only is output in non-production builds: https://github.com/radix-ui/primitives/blob/8175208cdbb8577e53f1165678ee0ce28a801837/packages/react/dialog/src/Dialog.tsx#L412

However, a fix would be nice as it adds noise to the debug console when developing.

Zerebokep commented 2 months ago

No idea if it fits your component, but you could just use the radix VisuallyHidden component:

      <VisuallyHidden.Root>
        <Dialog.Title>{title}</Dialog.Title>
      </VisuallyHidden.Root>

and for the other warning (Dialog.Content) add aria-describedby={undefined}