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

[bug]: Incorrect Usage of <DrawerClose> in Documentation Causes HTML Button Nesting Error #4662

Open
2 tasks done
Tchano-Py opened this issue Aug 29, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Tchano-Py
Copy link

Tchano-Py commented Aug 29, 2024

Describe the bug

I noticed an issue in the documentation for the component that could cause HTML hydration errors. The current example has a element nested inside another element, which is invalid in HTML and leads to the following warning:

Warning: In HTML <button> cannot be a descendant of <button>. This will cause a hydration error.

The current documentation demonstrates the usage of the Drawer component as follows:

<Drawer>
  <DrawerTrigger>Open</DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Are you absolutely sure?</DrawerTitle>
      <DrawerDescription>This action cannot be undone.</DrawerDescription>
    </DrawerHeader>
    <DrawerFooter>
      <Button>Submit</Button>
      <DrawerClose> // <---
        <Button variant="outline">Cancel</Button>
      </DrawerClose>
    </DrawerFooter>
  </DrawerContent>
</Drawer>

The recommended fix is to update the documentation to include the asChild property on , as shown below:

<Drawer>
  <DrawerTrigger>Open</DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Are you absolutely sure?</DrawerTitle>
      <DrawerDescription>This action cannot be undone.</DrawerDescription>
    </DrawerHeader>
    <DrawerFooter>
      <Button>Submit</Button>
      <DrawerClose asChild> // <---
        <Button variant="outline">Cancel</Button>
      </DrawerClose>
    </DrawerFooter>
  </DrawerContent>
</Drawer>

Affected component/components

DrawerClose

How to reproduce

  • Implement the code as per the current documentation.

  • Observe the hydration error in the browser console.

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Operating System: Windows 11
Browser: Microsoft Edge

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues

@Tchano-Py Tchano-Py added the bug Something isn't working label Aug 29, 2024
@kewldan
Copy link

kewldan commented Sep 21, 2024

I have created a PR for fixing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants