axe-core icon indicating copy to clipboard operation
axe-core copied to clipboard

False positive: 'color-contrast' rule fails disabled control's label added using "aria-describedby" attribute

Open adrianaferrugento opened this issue 1 year ago • 13 comments

Product

axe-core

Product Version

4.9.0

Latest Version

  • [X] I have tested the issue with the latest version of the product

Issue Description

Same as 2090, but here the label is added using aria-describedby attribute

Per WCAG 1.4.3 the text that is part of an inactive user interface component do not have contrast requirement.

Incidental: Text or images of text that are part of an inactive user interface component, that are pure decoration, that are not visible to anyone, or that are part of a picture that contains significant other visual content, have no contrast requirement.

Expectation

'color-contrast' would not fail for labels related to disabled controls

Actual

'color-contrast' rule fails for a label( added using aria-describedby attribute) of a disabled control

How to Reproduce

Screenshot 2024-04-11 at 16 28 26

adrianaferrugento avatar Apr 11 '24 15:04 adrianaferrugento

Thanks for the issue. From the screenshot I believe the issue is that the input element is not truly disabled. If you'd like to disable it you'll need to use disabled or aria-disabled=true, as data-disabled is not recognized by the browser as disabling the input.

straker avatar Apr 11 '24 15:04 straker

Hi @straker, thank you for the quick reply! Our textarea element does have disabled set on it and it still doesn't recognise the aria-describedby element as being part of that component.

adrianaferrugento avatar Apr 11 '24 16:04 adrianaferrugento

Gotcha. I see what you mean. I'll have to ask the team about what should happen in these cases. I'll let you know when I get an answer.

straker avatar Apr 11 '24 16:04 straker

Amazing, thank you!

adrianaferrugento avatar Apr 12 '24 08:04 adrianaferrugento

I agree with @adrianaferrugento on this one. There's a very good chance that if a control is disabled, things related to that control are not intended to be used. Ignoring an element referenced with aria-describedby feels reasonable. I'd say aria-errormessage and aria-controls should get that treatment too.

I think we should consider going a step further than that even and try to identify the container group (fieldset, radiogroup, etc), if all controls in a group are disabled, all text in it can be skipped in contrast testing. Either that or we set it as needs review. We'll look at that when we get to fixing this.

WilcoFiers avatar Apr 16 '24 11:04 WilcoFiers

Adding to this image https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum

WCAG makes an explicit callout on disabled elements as incidentals and we are also affected by this

image image

is this officially a false positive just for the sake of people coming in from google?

yuri-scarbaci-lenio avatar Jun 18 '24 13:06 yuri-scarbaci-lenio

the disabled attribute is invalid for use on a <div>

dylanb avatar Jun 18 '24 16:06 dylanb

Oh you are 100% right, my bad and nice catch!

image image

image

switching to aria-disabled instead properly fix the axe-core report

yuri-scarbaci-lenio avatar Jun 25 '24 14:06 yuri-scarbaci-lenio

You should probably add a role of some sort to the item in question so it is semantically marked up

dylanb avatar Jun 25 '24 14:06 dylanb

@dylanb Could I ask why you closed this issue? It still hasn't been fixed to my knowledge? My problem is with a textarea and the label that it's describing it and not a div

adrianaferrugento avatar Jun 25 '24 14:06 adrianaferrugento

yep, will review this more in depth on my side ASAP, for now that text is properly announced by screen readers as it is linked via the input labelled-by constraint and there is an internal javascript also handling some edge-cases and such with announcement, it has been manually tested to be compliant (but ofcourse there is always space for improvements) and the concern was mainly axe-core reporting this as a violation during the static analysis (which was 100% on point and I will consider adding some more html analysis tools to detect html violation to the flow too to avoid issues as this in the future)

Once again thanks you for helping me identify this

yuri-scarbaci-lenio avatar Jun 25 '24 14:06 yuri-scarbaci-lenio

@adrianaferrugento sorry, it seems like there are two different issues with different source code getting mixed up here, will re-open

dylanb avatar Jun 25 '24 14:06 dylanb

No worries, thank you @dylanb!

adrianaferrugento avatar Jun 25 '24 14:06 adrianaferrugento