-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
a11y: fix wrong role for day button #1708
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e6e658e
chore(accessibility): update roles
Kosai106 47ffceb
Merge branch 'master' into chore/accessibility-roles
gpbl cad99ac
Remove unwanted rule
gpbl 19af7e0
Merge branch 'master' into chore/accessibility-roles
gpbl 1634c42
Merge branch 'chore/accessibility-roles' of github.com:Kosai106/react…
gpbl 8bd5af6
Merge branch 'master' into chore/accessibility-roles
gpbl File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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 @@ | ||
import { configureAxe } from 'jest-axe'; | ||
|
||
export const axe = configureAxe({ | ||
rules: { | ||
'aria-allowed-role': { enabled: false } | ||
} | ||
}); | ||
export const axe = configureAxe(); |
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.
I believe this will break accessibility in some ways because
button
elements are not supposed to be children ofgrid > rowgroup
. I would recommend testing any changes with a screen reader.I've found that the structure that makes the most sense is to add a
div
with the role ofgridcell
and thebutton
inside thegridcell
. Additionally, using thearia-pressed
attribute for the button when it is selected (sincearia-selected
is not valid attribute forbutton
elements, and simply havingaria-selected
in thegridcell
did not work in VoiceOver. [as in, it didn't announce that the day was selected]). Addingaria-pressed
changes the buttons totoggle
buttons, which seems appropriate since a date is either selected or not selected.So
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.
You can possibly consider removing the
div
and changingrole="presentation"
torole="gridcell"
in thetd
element. But please test in a screen reader.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.
@GeorgeTaveras1231 thanks for your feedback here. Screen readers do read better the calendar when overriding roles, but the aXe test that doesn't like that.
I believe the correct HTML is to render a grid with grid cells being clickable, focusable, and "aria-selected". However, for some old design choices, we have now a button instead of a grid cell. Not easy to change the underlying HTML without introducing breaking changes.
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.
@gpbl 🤔 I have doubts about this approach. From my research it seems
gridcell
elements are grouping elements (except when the content is editable [think spreadsheet, for example]). In which case, clicking on the cells is just used to focus on the cell to allow the user to type. The way in which theDayPicker
works, each Day behaves as a toggle button. Clicking on it, toggles the selected/unselected state. Agridcell
by itself wont be able to communicate the sort of interactions each Day supports, as well as a toggle button can.I also looked at the ARIA role hierarchy to support this point, where you can see interactive elements generally stem from the abstract
widget
role. There you'll see thebutton
role, whereas thegridcell
role inherits fromsection
, which is astructure
role, and is mainly for grouping content.Resources:
gridcell
'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.
Additionally you can consider making each day a
checkbox
orradio
depending on themode
(single
->radio
;multiple
->checkbox
) 💡