scottaohara / a11y_accordions Goto Github PK
View Code? Open in Web Editor NEWES5 ARIA Accordion Component
Home Page: https://scottaohara.github.io/a11y_accordions/
License: MIT License
ES5 ARIA Accordion Component
Home Page: https://scottaohara.github.io/a11y_accordions/
License: MIT License
Ran into an issue where I needed some SPAN
content passed thru to the button text. Ex: a FontAwesome I
tag.
In your ARIAaccordion.setupHeadingButton
function the following changes did the trick.
// dhj; var buttonText;
var headingNodes;
...
// dhj; buttonText = heading.textContent;
headingNodes = heading.cloneNode(true); // clone the heading contents
// if you waited to delete the heading contents, you can skip the cloning
...
//dhj; newButton.appendChild(doc.createTextNode(buttonText));
while( headingNodes.childNodes.length > 0 ) { // loop thru the heading content
newButton.appendChild(headingNodes.childNodes[0]); // adding the nodes to the button
}
So, there ya go.
It might be something useful.
Share and enjoy.
dhj
Hi there,
This is not an issue. Rather than clicking the heading to close panel. Is there an attribute which we can attached in button which sit inside it's respective panel and closes it. Still new to JS world so any help will be highly appropriated.
many thanks
Sumanita
First of all thank you for giving us this accordion module, it's very generous of you.
I am testing its operation under different browsers.
In Firefox, when the panel opens I see a vertical scroll bar on the right. Once the panel is open, the bar disappears.
With Safari, Goocle Chrome and Opera this bar does not appear.
My question how to remove this bar in Firefox?
Thanks
OS X : 10.14.5
Safari : 12.1.1
Firefox : 67.0
Firefox Developer Edition : 68.0b5
Google Chrome : 74.0.3729.131
Opera : 60.0.3255.125
When focusing an active accordion trigger a unique focus style should be available
This should just require a new css focus selector for the button when in the aria-expanded state
in firefox, when hitting the spacebar on a generated to open/close a panel, the function is firing twice, not allowing a panel to effectively be opened or closed.
this issue only happens in firefox.
Add in feature for use of data-class
attribute, where the set value will be the baseline class that the accordion wrapper will have applied to it, and child elements will use as it's BEM base.
e.g.
data-class="my-acc"
should produce:
.my-acc
.my-acc__heading
.my-acc__panel
etc.
Home
and Shift
+ Tab
keys do not work. Tested on Accessible accordions demo page on Windows 7, Chrome 77.
As written, with multiple accordions, there's a possibility that the same randomly-generated id
could be applied to multiple elements.
Might be safer to do something like this toward the top of your closure:
var idCounter = 0;
Then, at the top of Accordion.create()
(before the loop starts)
idCounter += 1;
And to generate the actual id
per element:
self.id = 'acc_' + idCounter + '-' + i;
This way, since you're auto-incrementing, it impossible to ever have any collisions (until you get to 9007199254740991
, which is the maximum safe integer in JS and – you know – probably not gonna be a problem).
Per the ARIA Authoring Practices, finish work on the optional functionality to allow for up and down arrows to navigate between panel triggers.
This behavior is not typically expected to all screen reader users, and may be confusing if the accordion panels do not contain focusable elements for a user to tab to.
Hi there,
it would be helpful to publish this library as a NPM package, so it can be imported and updated easily.
not sure if this is the place for questions, but I'm trying to get 2 different lines of text in my "header" an h2 and a p.
<li class="accordion-item">
<img src="<?php the_sub_field('image'); ?>" />
<h2 class="accordion-heading" data-aria-accordion-heading><?php the_sub_field('title'); ?></h2>
*(Ideally another line of text here)*
<div class="accordion-panel" data-aria-accordion-panel>
<p><?php the_sub_field('main_content'); ?></p>
</div>
</li>
I've tried inserting it inside the h2, putting it below the h2, adding a div to hold the h2 and the p. those all seem to break the button.
any direction would be awesome!
(you can see it here if you'd like: https://globaltoolkit.wpengine.com/test-page/) down at the bottom.
Originally posted by @RidgeviewTech in #7 (comment)
Hello, I have been using your accordion and it's great.
But I have a question.
Inside each panel I have a button that says 'next step'. If it clicked it will open the next panel.
I used jquery to simulate a click on the accordion header (trigger?) when 'next step' is clicked.
It does open the next panel, however the opened panel class is 'was-active', and the previous panel class is still 'is-active'
How can I fix this? sorry if my explanation is confusing. Hope you can help. Thanks!
First of all, great job!
The query selector you use for accordion headings/panels contained within an ol/ul list returns all descendant headings/panels in the main accordion (as well as the nested ones).
Currently:
panels = doc.querySelectorAll('#' + self.id + ' li > ' + widgetPanel);
headings = doc.querySelectorAll('#' + self.id + ' li > ' + widgetHeading);
Should be:
panels = doc.querySelectorAll('#' + self.id + ' > li > ' + widgetPanel);
headings = doc.querySelectorAll('#' + self.id + ' > li > ' + widgetHeading);
per w3c aria-practices issue i opened about accordions:
"We are replacing the accordian design pattern with one that does not use the tab or tabpanel roles."
so this will need to change soon
Accordions should be allowed to be created without the triggers needing to be within heading elements.
This would make far more sense for instances of them being used within list elements.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.