-
Notifications
You must be signed in to change notification settings - Fork 899
fix(landmark-unique): exclude section/form with non-landmark roles from landmark match #5085
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,9 @@ | ||
| import { getRoleType } from '../commons/aria'; | ||
| import { isVisibleToScreenReaders } from '../commons/dom'; | ||
| import { getRole } from '../commons/aria'; | ||
| import { getAriaRolesByType } from '../commons/standards'; | ||
| import { accessibleTextVirtual } from '../commons/text'; | ||
|
|
||
| export default function landmarkUniqueMatches(node, virtualNode) { | ||
| return ( | ||
| isLandmarkVirtual(virtualNode) && isVisibleToScreenReaders(virtualNode) | ||
| getRoleType(virtualNode) === 'landmark' && | ||
| isVisibleToScreenReaders(virtualNode) | ||
| ); | ||
| } | ||
|
|
||
| function isLandmarkVirtual(vNode) { | ||
| const landmarkRoles = getAriaRolesByType('landmark'); | ||
| const role = getRole(vNode); | ||
| if (!role) { | ||
| return false; | ||
| } | ||
|
|
||
| const { nodeName } = vNode.props; | ||
|
|
||
| if (nodeName === 'section' || nodeName === 'form') { | ||
| const accessibleText = accessibleTextVirtual(vNode); | ||
| return !!accessibleText; | ||
| } | ||
|
|
||
| return landmarkRoles.indexOf(role) >= 0 || role === 'region'; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,17 @@ | |||||||||||||||||||||||||||||||||||||||||
| <form id="pass-form-aria-label-1" aria-label="form-label-1"></form> | ||||||||||||||||||||||||||||||||||||||||||
| <form id="pass-form-aria-label-2" aria-label="form-label-2"></form> | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| <form | ||||||||||||||||||||||||||||||||||||||||||
| id="pass-form-search-aria-label-1" | ||||||||||||||||||||||||||||||||||||||||||
| role="search" | ||||||||||||||||||||||||||||||||||||||||||
| aria-label="form-search-label-1" | ||||||||||||||||||||||||||||||||||||||||||
| ></form> | ||||||||||||||||||||||||||||||||||||||||||
| <form | ||||||||||||||||||||||||||||||||||||||||||
| id="pass-form-search-aria-label-2" | ||||||||||||||||||||||||||||||||||||||||||
| role="search" | ||||||||||||||||||||||||||||||||||||||||||
| aria-label="form-search-label-2" | ||||||||||||||||||||||||||||||||||||||||||
| ></form> | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+17
Contributor
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. This is the false positive of the original issue. Good to have that in the E2E suite.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| <div id="form-label-1">form-with-label-1</div> | ||||||||||||||||||||||||||||||||||||||||||
| <div id="form-label-2">form-with-label-2</div> | ||||||||||||||||||||||||||||||||||||||||||
| <form id="pass-form-aria-labelledby-1" aria-labelledby="form-label-1"></form> | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,8 @@ | |||||||||
| ["#pass-header"], | ||||||||||
| ["#pass-form-aria-label-1"], | ||||||||||
| ["#pass-form-aria-label-2"], | ||||||||||
| ["#pass-form-search-aria-label-1"], | ||||||||||
| ["#pass-form-search-aria-label-2"], | ||||||||||
|
Comment on lines
+9
to
+10
Contributor
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.
Suggested change
Contributor
Author
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. Thanks for the suggestion. I tried applying the suggested JSON change by adding these selectors, but the integration test fails with Also, I originally added the |
||||||||||
| ["#pass-form-aria-labelledby-1"], | ||||||||||
| ["#pass-form-aria-labelledby-2"], | ||||||||||
| ["#pass-aside-aria-label-1"], | ||||||||||
|
|
||||||||||
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.
Ideally, I wanted to add new test cases for
<section>/<form>with a landmark role but noaria-label. However, all landmark roles were already used in the no-label section of this file, so there was no available role to use for new elements. Instead, I replaced the existing<div role="search">with<form role="search">.