question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AccordionItem - using, and accessibility issue

See original GitHub issue

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 <button> and is considered an interactive element so having a button in it is like having a button nested within a button something which react doesn’t like

 const getTitle = (name, description, buttonText, page, link) => {
    return (
      <React.Fragment>
        <div className={`${COMPONENT_NAME}__title-text`}>
          <div className={`${COMPONENT_NAME}__name`}>{name}</div>
          <div className={`${COMPONENT_NAME}__description`}>
            {description}
          </div>
          <Button
            className={`${COMPONENT_NAME}__title-button`}
            href={link}
            target='blank'
            kind='tertiary'
            onClick={() => routeTo(page)}
          >{buttonText}</Button>
        </div>
      </React.Fragment>
    );
  };

 <AccordionItem
          className={`${COMPONENT_NAME}__title`}
          title={
            getTitle(
              t('overview.steps.addSecretName'),
              <Trans i18nKey='overview.steps.addSecretDescription' components={[getLinkElement()]}/>,
              t('overview.steps.addSecretButton'),
              'addSecret',
              null
            )
          }>
          {
            getContent(
              <VideoPlayer src={getMediaUrl('GIF_1.mp4')} />,
              true,
              t('overview.steps.addSecretNotificationTitle'),
              <Trans i18nKey='overview.steps.addSecretNotificationSubtitle' components={[getSettingsLink()]}/>,
              <Trans i18nKey='overview.steps.addSecretDetails' components={[setBoldTreatment()]}/>
            )
          }
        </AccordionItem>

There is also an accessibility issue here, because AccordionItem is a Button then all the text inside it is read at the same time when moving through it, also if I put a link, it is not read by Jaws (insert+F7) links, and cannot be used correctly (user does not know on which element he is on).

I think changing the AccordionItem to div would fixed all these issues (I checked and changed it locally in the html page to div and that fixed it). When it was button, Jaws did not recognize the Learn more link)

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
joshblackcommented, Dec 7, 2020

@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.

1reaction
joshblackcommented, Nov 30, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessible Accordion - examples and best practices - Aditus
Accordions are a common UX pattern that can help reduce the amount of information presented to users. You might recognise this pattern by...
Read more >
Accordions | Accessibility Guidelines
Accordions. Accordions are common design structures used to organize and hide content, so as not to overwhelm the user. Accordions are also web...
Read more >
Accordion accessibility issue - OutSystems
The accordion component and AccordionItem code that is generated is failing the accessibility check. The main accordion div is created with ...
Read more >
Accordion Example | APG | WAI - W3C
Defines the accessible name for the region element. References the accordion header button that expands and collapses the region.
Read more >
Accessibility issue with pure CSS accordion - Stack Overflow
To start with, you shouldn't be using a checkbox to collapse/expand any element (bad practice). You can instead use a <button> that would ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found