twbs / twbs/bootstrap

Collapse’s `aria-expanded` attribute never leaves `true` state.

Open
#40,841 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

js v5
Dominant language
MDX
Stars
175k
Forks
78.6k
Avg merge
7h 19m
Merged PRs (30d)
35

Description

Prerequisites
Describe the issue

When a Collapse trigger is clicked, it should update the trigger’s aria-expanded attribute from "true" to "false" and vice versa. The test case shows that only the change from "false" to "true" happens. The attribute never gets updated again when the trigger is clicked again.

Note that the change from "false" to "true" doesn’t happen either if the div.collapse is removed. This might be by design, but I think this is a bug, too. There might be nothing to display at the time the trigger is clicked, but IMHO, the element still got expanded and should reflect that.

The reason I care about this is because I show an icon to display if a collapsible element is currently collapsed. Similar to the demo, I update the icon in CSS based on the trigger’s aria-expanded attribute.

Reduced test cases

https://stackblitz.com/edit/stackblitz-starters-zhsmta?file=index.html

What operating system(s) are you seeing the problem on?

Linux

What browser(s) are you seeing the problem on?

Chrome, Firefox

What version of Bootstrap are you using?

5.3.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reduced StackBlitz test case and trace the Bootstrap 5.3.3 Collapse trigger behavior in both Chrome and Firefox. Verify that repeated clicks toggle aria-expanded between true and false, including when the target div.collapse has been removed; the issue is done when the attribute consistently reflects the trigger state.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, html, javascript
Domain
accessibility, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.