-
Notifications
You must be signed in to change notification settings - Fork 779
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
Possible false positive for label-title-only, caused by aria-describedby #3174
Comments
Thanks for the issue. The reason this happens is that the check looks to see if the input does not have a label but uses However the label is read by screen readers even if it is hidden. That's why the |
We determined that this is indeed a false positive. |
a fix is implemented in #3183 |
I noticed that the prior fix seems to only account for elements that have At first I thought it made sense that a label provided programmatically to assistive tech but not visually would raise a violation, but then I noticed that even with the non-visual <!--
Copyright 2023 Google LLC.
SPDX-License-Identifier: Apache-2.0
-->
<span id="description">Description</span>
<!-- Does not raise label-title-only violation because of fix -->
<span id="aria-hidden-label" aria-hidden="true">ARIA hidden label</span>
<input aria-labelledby="aria-hidden-label" aria-describedby="description" />
<!-- Raises label-title-only violation -->
<span id="no-display-label" style="display: none">Label not displayed visually</span>
<input aria-labelledby="no-display-label" aria-describedby="description" />
<!-- Does not raise label-title-only violation -->
<span id="no-visibility-label" style="visibility: hidden">Label not displayed visually</span>
<input aria-labelledby="no-visibility-label" aria-describedby="description" />
<!-- Does not raise label-title-only violation -->
<input aria-label="Label not displayed visually" aria-describedby="description" /> I tested this with v4.7.0 and with Chrome+VoiceOver. |
@nolandanley Would you mind opening a new issue for that? We recently refactored how we handle detecting visibility on elements (screen reader vs visual) so we might just need to move over to that since they didn't exist when the original fix for this issue was created. |
Product
axe-core
Description:
I think I may have found a false positive bug for the label-title-only rule when using a combination of
aria-labelledby
,aria-describedby
andaria-hidden
on the labelling element.Reproduced and explained here: https://codepen.io/fymmot/full/XWgQJLw
(My purpose for using aria-labelledby and aria-hidden in this way is to avoid duplicate announcements of the label texts for screen reader users. In our particular use case, we are using multiple elements to construct the label, which causes multiple swipes or down arrow interactions to move past it for the user.)
Expectation:
I expect that I can label an
<input type="radio">
usingaria-labelledby
and havingaria-hidden
set on the labelling element.I also expect that I can use
aria-describedby
on the same<input>
, without it triggering alabel-title-only
error in aXe.Actual:
When using a combination of
aria-labelledby
,aria-hidden
andaria-describedby
, aXe throws alabel-title-only
error.I also get the same error if using
hidden
instead ofaria-hidden
.I can remove the error by removing the
aria-describedby
attribute but keepingaria-labelledby
.I can also fix the error by removing
aria-hidden
orhidden
from the labelling element.Motivation:
This behavior does not seem logical, or intended. I don't think the presence of aria-describedby should affect the label-title-only test, as long as the aria-labelledby is valid.
If the combination of aria-labelledby and aria-hidden is discouraged or disallowed, it should throw an error regardless of aria-describedby, which it does not
The text was updated successfully, but these errors were encountered: