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.

[Docs] Accessibility : Should add aria-expanded and aria-controls for Collapse toggle

See original GitHub issue

For accessibility we should add aria-expanded and aria-controls for Collapse toggle: https://react-bootstrap.github.io/components.html#transitions-collapse

class Example extends React.Component {
  constructor(...args) {
    super(...args);

    this.state = {};
  }

  render() {
    return (
      <div>
        <Button onClick={ ()=> this.setState({ open: !this.state.open })}>
          click
        </Button>
        <Collapse in={this.state.open}>
          <div>
            <Well>
              Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.
              Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
            </Well>
          </div>
        </Collapse>
      </div>
    );
  }
}

ReactDOM.render(<Example/>, mountNode);

The accessible one:

class Example extends React.Component {
  constructor(...args) {
    super(...args);

    this.state = {
        open: false
    };
  }

  render() {
    return (
      <div>
        <Button onClick={ ()=> this.setState({ open: !this.state.open })} aria-expanded={this.state.open} aria-controls="collapseExample">
          click
        </Button>
        <Collapse in={this.state.open}>
          <div id="collapseExample">
            <Well>
              Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid.
              Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
            </Well>
          </div>
        </Collapse>
      </div>
    );
  }
}

ReactDOM.render(<Example/>, mountNode);

Bootstrap example: https://getbootstrap.com/docs/4.0/components/collapse/

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jquensecommented, Mar 26, 2018

yup! please go for it 👍

1reaction
taioncommented, Dec 19, 2017

We’re definitely open to PRs here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

aria-expanded - Accessibility - MDN Web Docs - Mozilla
The aria-expanded attribute is set on an element to indicate if a control is expanded or collapsed, and whether or not its child...
Read more >
Using the WAI-ARIA aria-expanded state to mark ...
Example 1: Using a button to collapse and expand a region​​ The state of the paragraph is represented by the attribute aria-expanded on...
Read more >
Collapse · Bootstrap
Toggle the visibility of content across your project with a few classes and our JavaScript plugins.
Read more >
Collapse · Bootstrap
The Bootstrap collapse plugin allows you to toggle content on your pages with a few ... aria-expanded="false" aria-controls="collapseExample"> Button with ...
Read more >
What you need to know about ARIA and how to fix common ...
ARIA, or Accessible Rich Internet Applications, is HTML used to make webpages more accessible. Not all HTML elements have accessibility ...
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