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

Harden accordion Javascript against accordions that have no buttons #444

Closed
3 tasks done
underdarknl opened this issue Dec 16, 2023 · 0 comments · Fixed by #574
Closed
3 tasks done

Harden accordion Javascript against accordions that have no buttons #444

underdarknl opened this issue Dec 16, 2023 · 0 comments · Fixed by #574
Labels
Helper classes Component 'Helper classes' javascript Pull requests that update Javascript code

Comments

@underdarknl
Copy link
Contributor

underdarknl commented Dec 16, 2023

Describe the bug, issue or concern

Accordions that exists but have not buttons currently crash the JS on the line:
buttons[0].setAttribute("aria-expanded", "true")

We should check if at least one button is available before trying to set it to expanded.

Im also not sure about the check for the aria-expanded value by just using getAttribute, as that also returns True for 'false' strings when used like this: if(elem.getAttribute('aria-expanded')) on <elem aria-explanded="false"></elem> which is not what the code expects to do on line 48 of accordion.js

To Reproduce

Steps to reproduce the behavior:

  1. Create two accordions on one page
  2. Make sure one has no buttons
  3. Notice both have not initialized as expected.
  4. See error console

Expected behavior

Init all accordions as properly as possible

Governance

@underdarknl underdarknl added the javascript Pull requests that update Javascript code label Dec 16, 2023
@ppvg ppvg changed the title harder accordion Javascript against accordions that have no buttons Harden accordion Javascript against accordions that have no buttons May 8, 2024
underdarknl added a commit that referenced this issue Jul 8, 2024
@reinschaap reinschaap added the Helper classes Component 'Helper classes' label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Helper classes Component 'Helper classes' javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants