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

[Accordion] AccordionSummary button validateDOMNesting warning #45187

Closed
orenBerko opened this issue Feb 3, 2025 · 8 comments
Closed

[Accordion] AccordionSummary button validateDOMNesting warning #45187

orenBerko opened this issue Feb 3, 2025 · 8 comments
Labels
component: accordion This is the name of the generic UI component, not the React module! support: Stack Overflow Please ask the community on Stack Overflow

Comments

@orenBerko
Copy link

orenBerko commented Feb 3, 2025

Steps to reproduce

Steps:

  1. Open this link to live example: (required)

Current behavior

the accordion Summary is html button and in my add i add buttons inside the summary and i get this warning:
validateDOMNesting(...): cannot appear as a descendant of . Error Component Stack
after investigation i see that the summary is MuiButtonBase-root and this is the problem button inside buttons
in the previous version did not have this error

Expected behavior

i think you need an option to change the container to be div or something else from button

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: Accordion,Summary

@orenBerko orenBerko added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 3, 2025
@mnajdova
Copy link
Member

mnajdova commented Feb 3, 2025

Can you provide an example of what you are trying to achieve? Codesandbox/Stackblitz example would be great. Are you trying to customze the AccordionSummary button and use a custom one? It is intentional that this component renders a button by default.

@mnajdova mnajdova added status: waiting for author Issue with insufficient information component: accordion This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 3, 2025
@mj12albert
Copy link
Member

mj12albert commented Feb 3, 2025

an option to change the container to be div or something else from button

@orenBerko AccordionSummary is intended to be a button, so placing buttons inside a button seems like a strange UX to begin with?

However to make it render a div instead you can use the component prop for this:

<AccordionSummary component="div" role="button" />

(disclaimer: this is terrible for accessibility, interactive elements should never be nested)

@mj12albert mj12albert added support: Stack Overflow Please ask the community on Stack Overflow and removed status: waiting for author Issue with insufficient information labels Feb 3, 2025
@mj12albert mj12albert changed the title Accordion Summary Button validateDOMNesting warning [Accordion] AccordionSummary button validateDOMNesting warning Feb 3, 2025

This comment has been minimized.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
@orenBerko
Copy link
Author

orenBerko commented Feb 3, 2025

@mj12albert the component is not a member of AccordionSummary so you solution not work for me
https://mui.com/material-ui/api/accordion-summary/
add here my need's of the summary with buttons:

Image

@mnajdova FYI

@mj12albert mj12albert reopened this Feb 3, 2025
@github-actions github-actions bot removed the support: Stack Overflow Please ask the community on Stack Overflow label Feb 3, 2025
@mj12albert

This comment has been minimized.

@orenBerko

This comment has been minimized.

@mj12albert
Copy link
Member

mj12albert commented Feb 3, 2025

the component is not a member of AccordionSummary so you solution not work for me
https://mui.com/material-ui/api/accordion-summary/

@orenBerko Sorry I misread this, the component prop works, the props of ButtonBase are also available on AccordionSummary, see the line/link under this heading: https://mui.com/material-ui/api/accordion-summary/#props

Sandbox: https://codesandbox.io/p/sandbox/goofy-sky-fccdx8-fccdx8?file=%2Fsrc%2FDemo.tsx%3A18%2C29-20%2C24

DISCLAIMER: this may pass html validators but it's terrible for a11y, interactive elements like buttons should never be nested: https://adrianroselli.com/2016/12/be-wary-of-nesting-roles.html

@mj12albert mj12albert added the support: Stack Overflow Please ask the community on Stack Overflow label Feb 3, 2025
Copy link

github-actions bot commented Feb 3, 2025

👋 Thanks for using this project!

We use GitHub issues exclusively as a bug and feature requests tracker, however, this issue appears to be a support request.

For support with Material UI please check out https://mui.com/material-ui/getting-started/support/. Thanks!

If you have a question on Stack Overflow, you are welcome to link to it here, it might help others.
If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: accordion This is the name of the generic UI component, not the React module! support: Stack Overflow Please ask the community on Stack Overflow
Projects
None yet
Development

No branches or pull requests

3 participants