Carbon: AccordionItem - using, and accessibility issue

Created on 30 Nov 2020  路  6Comments  路  Source: carbon-design-system/carbon

According to https://pages.github.ibm.com/ibmcloud/pal/patterns/getting-started-tab/usage it is a known design to put a button in the accordion:

image

However, when we try it we get a big error
Warning: validateDOMNesting(...): <button> cannot appear as a descendant of <button>.

because the accordion header itself is rendered as a

waiting for author's response 馃挰 bug 馃悰

Most helpful comment

@alon24 unfortunately I think the problem is that you can't nest buttons, and the trigger for the accordion (which takes up the full width) is a button so anything inside of it will need to be non-interactive.

All 6 comments

@carbon-design-system/design Are we allowing Button's to be placed in the Accordion Title?

@dakahn any a11y concerns with changing this from a button to a div with a role of button?

Unfortunately, if you nest buttons then it removes the semantics of the inner button 馃槥 This would apply to nesting the <button> element along with role="button" and a nested button.

For example:

<div role="button" tabindex="0">
  Toggle
  <button>Submit</button>
</div>

Would read as: Toggle Submit. A screen reader like VoiceOver would be unable to navigate to the inner button (Submit) 馃槥

Typically the remedy to this is to separate out the two actions instead of nesting one inside of the other.

Any update on this? or was the solution here, NOT to use button, and you guys are not moving to div?

@alon24 unfortunately I think the problem is that you can't nest buttons, and the trigger for the accordion (which takes up the full width) is a button so anything inside of it will need to be non-interactive.

Closing! Can reopen if we need to though.

Was this page helpful?
0 / 5 - 0 ratings