-
Notifications
You must be signed in to change notification settings - Fork 32
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
Issue #47: fix a11y eslint errors #53
Open
thumbsupep
wants to merge
6
commits into
godaddy:main
Choose a base branch
from
thumbsupep:fix-eslint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2286d6f
add roles
epramer-godaddy f2c7333
add onFocus
epramer-godaddy 32986c7
ignore specific line for a11y
epramer-godaddy 854f2ad
stub tests
epramer-godaddy ecb3c8a
flesh out tests
epramer-godaddy 1cc74a2
finish tests
epramer-godaddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
/* eslint | ||
jsx-a11y/mouse-events-have-key-events: 0, | ||
jsx-a11y/no-noninteractive-element-interactions: 0, | ||
jsx-a11y/click-events-have-key-events: 0 */ | ||
import React, { Component, Children, cloneElement } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import nth from 'lodash.nth'; | ||
|
@@ -471,13 +467,15 @@ export default class Carousel extends Component { | |
} | ||
<div className='carousel-viewport' ref={ v => { this._viewport = v; } } style={ viewportStyle }> | ||
<ul | ||
role='tablist' | ||
className='carousel-track' | ||
style={ trackStyle } | ||
ref={ t => { this._track = t; } } | ||
onTransitionEnd={ this.slideTransitionEnd } | ||
onMouseDown={ this.onMouseDown } | ||
onMouseLeave={ this.onMouseLeave } | ||
onMouseOver={ this.onMouseOver } | ||
onFocus={ this.onMouseOver } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this also need an |
||
onMouseEnter={ this.onMouseEnter } | ||
onTouchStart={ this.onTouchStart } | ||
> | ||
|
@@ -565,7 +563,12 @@ export default class Carousel extends Component { | |
} | ||
|
||
return ( | ||
// key handler is not needed due to the tab role - tab + enter | ||
// performs the same function as onClick | ||
// eslint-disable-next-line jsx-a11y/click-events-have-key-events | ||
<li | ||
role='tab' | ||
aria-selected={ index === currentSlide } | ||
key={ key } | ||
style={ slideStyle } | ||
data-index={ index } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
tablist
/tab
the right role here?From https://www.w3.org/WAI/PF/HTML/wiki/RoleAttribute#ARIA_1.0_Pre-Defined_Roles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it has to be an interactive role. I'm not sure where to find a comprehensive list of which ones are interactive - but I found this list https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md#rule-details
and
tab
seems correct if you replace the wordtab
withslide
in "selecting a different tab changes the content and makes the selected tab more prominent than the other tabs" https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Roleis there a better interactive role?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed to this role, and it's certainly better than whats already there. My only concern is that there's no "content" being shown, just the "tab" itself. i.e. a
tab
is supposed to effectively swap out the primarytabpanel
(or make it more prominent) and there's notabpanel
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If each image was a
tabpanel
and there were "dots" or some positional indicator that the user can click on/keyboard to activate a specific image, then those "dots" would betabs
. In the absence of dots/indicators, maybe tablist/tabpanel makes the most sense here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msluther @thumbsupep this is probably a good example to base off of https://www.w3.org/TR/wai-aria-practices-1.1/examples/carousel/carousel-1.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is probably fine, but it might be a good idea to add
aria-roledescription
attributes ofcarousel
andslide
just to be a bit more descriptive for screen readers. I did see this page that recommended that: https://www.w3.org/TR/wai-aria-practices-1.1/examples/carousel/carousel-1.html