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

Doesn't include aria-label as an option #125

Closed
judygab opened this issue Apr 3, 2020 · 2 comments
Closed

Doesn't include aria-label as an option #125

judygab opened this issue Apr 3, 2020 · 2 comments

Comments

@judygab
Copy link

judygab commented Apr 3, 2020

I'm using this plugin on a page and running through SiteImprove(one of the tools to check Web Accessibility issues is showing an error that 'Link Text is Too Generic in Its Current Context'. This is because Generic Text like 'Read More' is used. The way to solve this problem by adding aria-label to the link to provide more specific details, but I don't see that in the list of options in your documentation. Is this something that can be worked on?

@kswedberg
Copy link
Owner

There isn't a way within the plugin do this, but it's easy enough to do with jQuery. Here's a quick and dirty example of making this a little more accessible (you'll need to change selectors, etc to match the elements on your page, of course):

var setAriaCollapsed = function() {
  $(this).attr('aria-expanded', 'false')
  .find('.more-link').attr('aria-label', 'this is the label for the "read more" link');
};

var setAriaExpanded = function() {
  $(this).attr('aria-expanded', 'true')
  .find('.more-link').attr('aria-label', 'this is the label for the "read less" link');
};

$('.expander')
.expander({
  afterExpand: setAriaExpanded,
  afterCollapse: setAriaCollapsed
  // your other options
})
.each(setAriaCollapsed);

@judygab
Copy link
Author

judygab commented Apr 3, 2020

There isn't a way within the plugin do this, but it's easy enough to do with jQuery. Here's a quick and dirty example of making this a little more accessible (you'll need to change selectors, etc to match the elements on your page, of course):

var setAriaCollapsed = function() {
  $(this).attr('aria-expanded', 'false')
  .find('.more-link').attr('aria-label', 'this is the label for the "read more" link');
};

var setAriaExpanded = function() {
  $(this).attr('aria-expanded', 'true')
  .find('.more-link').attr('aria-label', 'this is the label for the "read less" link');
};

$('.expander')
.expander({
  afterExpand: setAriaExpanded,
  afterCollapse: setAriaCollapsed
  // your other options
})
.each(setAriaCollapsed);

This was helpful, thank you! Closing this issue

@judygab judygab closed this as completed Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants