Skip to content
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

Incorrect Reporting of: This element's role is "presentation" but contains child elements with semantic meaning. #191

Closed
tmcconechy opened this issue May 30, 2017 · 12 comments
Assignees
Labels

Comments

@tmcconechy
Copy link

Working with our screen reader users we figured out we need to define our icons like this or they can get read buy IE / Certain browsers and this covers all cases

    <button type="button" class="btn-icon" title="Attach">
       <svg class="icon" focusable="false" aria-hidden="true" role="presentation">
          <use xlink:href="#icon-attach"></use>
       </svg>
       <span>Attach</span>
    </button>

However, starting recently this now reports: This element's role is "presentation" but contains child elements with semantic meaning.

Should it skip the case of SVG elements with only use tags?

@tmcconechy tmcconechy changed the title Incorrect Reporting of This element's role is "presentation" but contains child elements with semantic meaning. Incorrect Reporting of: This element's role is "presentation" but contains child elements with semantic meaning. May 30, 2017
@matejlednar
Copy link

I would like to ask about this issue too. We have now cca 300 role presentation errors - Dojo Toolkit widgets. Does your error checker work well?

@ironikart ironikart self-assigned this Jun 1, 2017
@ironikart ironikart added the Bug label Jun 1, 2017
@tmcconechy
Copy link
Author

Thinking about this error. I cant think of any cases where this would be a error. If a developer decides to use role="presentation" then almost always 't they going to be hiding content/semantical elements for some reason.

http://www.w3.org/TR/wai-aria/roles#presentation

@matejlednar
Copy link

error sounds dangerous, maybe it should be classified as warning

@tmcconechy
Copy link
Author

Yeah, Maybe warning. "Make sure your content under role='presentation' really doesnt have semantic meaning"

@matejlednar
Copy link

in this case it is generated by Dojo Toolkit framework, its widgets.

@robfentress
Copy link

I also get this incorrect error on tables marked as presentational, even though they do not contain semantic table elements like <th>, or <caption>, which might really be expected to trigger a valid error.

@sgregson
Copy link
Contributor

sgregson commented Jan 8, 2018

I think the bug here is testing HTML elements which shouldn't be tested, not that the test is invalid. From the reference on https://www.w3.org/TR/wai-aria/roles#presentation

Many individuals erroneously consider role="presentation" to be synonymous with aria-hidden="true", and we believe role="none" conveys the actual meaning more unambiguously.

ie, role=presentation only negates semantics on that HTML element, not its children.

I was looking into the SVG issue and noticed that dropping role=presentation (to be only aria-hidden=true) removes the incorrect reporting, so I suspect it's coming from HTMLCS.js@2.1.1#L257. From that, the children of any node with role=presentation will get audited for semantics, regardless of whether it's been otherwise hidden from the Accessibility Tree.

@tmcconechy 's example would be addressed by tweaking the selector query of var presentationElems = topElement.querySelectorAll('[role="presentation"]'); to [role="presentation"]:not[aria-hidden="true"], but that doesn't cover other edge cases where aria-hidden could be set at a higher HTML element than the one using role=presentation. IMHO that's a pretty small edge case and the role=presentation shouldn't be assigned to children nodes of aria-hidden=true. Is there a more reliable way to check with HTMLCS whether the node is otherwise hidden from the AT?

@robfentress do you have some testable HTML? What you're describing sounds like a different root cause. Might be fixed by making the permitted whitelist of testSemanticPresentationRole element-specific 1_3_1.js#L107 I'd want a contributor to chime-in on whether that's the correct approach, however, before attempting to PR.

ironikart added a commit that referenced this issue Jan 8, 2018
…th role=presentation assigned and all parent nodes before checking any child elements that have semantic meaning.
@ironikart
Copy link
Contributor

Thanks @sgregson. I've updated with a small fix to test aria hidden on the element with role assigned and it's parent nodes.

The test for the issue @robfentress will require a little more research, but I suspect the expansion of the white list would be the simplest fix. If you'd like to submit a PR I'll assign some time to take a look at it.

@tmcconechy
Copy link
Author

I'm still getting the same number of reports on the "bookmarklet" tool. http://squizlabs.github.io/HTML_CodeSniffer/

Is that updated (or takes a while to update)?

@ironikart
Copy link
Contributor

Is that updated (or takes a while to update)?

We generally don't updated the bookmarklet until we've tagged a release so the currently bookmarklet code won't contain these fixes on the master branch. It's overdue so I'll organise a release with recent fixes in the near future.

@KittyGiraudel
Copy link

We have this problem on definition lists (dl) despite them not having aria-hidden or being child of an element with aria-hidden. Is it worth opening an issue regarding definition lists being incorrectly reported as presentational?

@ironikart
Copy link
Contributor

@hugogiraudel Sure, it's worth opening an issue. Paste some example failing content and I'll look into it.

ironikart added a commit that referenced this issue Aug 29, 2018
…. This resolves #229. Reference issue #191 where aria-hidden attribute could be used as a workaround to releases prior to this commit..
dochne pushed a commit to silktide/HTML_CodeSniffer that referenced this issue Mar 8, 2021
…lement with role=presentation assigned and all parent nodes before checking any child elements that have semantic meaning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants