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

Should img be named from content? #1330

Open
WilcoFiers opened this issue Sep 30, 2020 · 13 comments
Open

Should img be named from content? #1330

WilcoFiers opened this issue Sep 30, 2020 · 13 comments
Labels
feature may add new concept(s) to ARIA which will require implementations or APG changes
Milestone

Comments

@WilcoFiers
Copy link
Contributor

This came up during the AGWG call when discussing the svg element with explicit role has non-empty accessible name ACT rule. Why should an img only be named from author? Take the following example:

<svg xmlns="http://www.w3.org/2000/svg" role="img" width="100" height="100">
	<circle cx="50" cy="50" r="40" fill="yellow"></circle>
	<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle">
		Yellow circle
	</text>
</svg>

It seems a little counter-intuitive that the content of the text node isn't used to give this img an accessible name. Definitely if there is a title element, or aria-label that should be used, but absent those, wouldn't it make sense to use text content if there is any?

@carmacleod
Copy link
Contributor

SVG title element does name an image (in ACCNAME step 2D).

In the Yellow circle example, it may seem to make sense to allow name from content... however SVGs can have all sorts of text content, like all of the labels on a graph, or all of the instructions on a map, etc., which would result in a pretty verbose flat string that wouldn't be very useful as a name.

I think that the best naming strategy for the Yellow circle example is to use aria-labelledby to point to the Yellow circle text element.

@aleventhal
Copy link
Contributor

aleventhal commented Sep 30, 2020

role img has "Children Presentational: True", meaning that browsers may enforce them to be leaf objects. There would be no descendant content in the accessible tree. Since browsers use the accessible object subtree (and not DOM subtree), this might be a nonstarter.

Changing Children Presentational to be false is probably a no go as well, as ATs expect an image to be a leaf.

@WilcoFiers
Copy link
Contributor Author

@carmacleod I understand that it uses title if one exists, but why not have it fallback to text content if any exists?

@aleventhal I'm not suggesting to change presentational children. I agree with you that that could be problematic. But something can have presentational children and still be named from content. Buttons have this for example.

@carmacleod
Copy link
Contributor

@WilcoFiers

I understand that it uses title if one exists, but why not have it fallback to text content if any exists?

Because if we did that, then the name of this SVG would be "2008 2009 2010 2011 2012 15 10 5 0 Weeks".

@pkra
Copy link
Member

pkra commented Oct 5, 2020

This idea feels more like a suggestion for handling author errors, https://w3c.github.io/aria/#document-handling_author-errors.

@aleventhal
Copy link
Contributor

@aleventhal I'm not suggesting to change presentational children. I agree with you that that could be problematic. But something can have presentational children and still be named from content. Buttons have this for example.

Hmm, that's a good point. It might work.

Actually FYI neither Firefox nor Chrome enforce presentational children on buttons anymore, because there were too many cases where buttons had important interactive children. See issue #1174 .

@WilcoFiers
Copy link
Contributor Author

Because if we did that, then the name of this SVG would be "2008 2009 2010 2011 2012 15 10 5 0 Weeks".

Can you explain why that would be? The way I understand it, the title element in svg takes priority in the accessible name computation. Name from content only used if there is no native attribute/element to give an accessible name. At least, that's my reading of it.

@scottaohara
Copy link
Member

@WilcoFiers, Carolyn's example that you quoted has no <title>.

@WilcoFiers
Copy link
Contributor Author

@scottaohara My bad, but it does it have role=img either. How is it relevant to this?

@carmacleod
Copy link
Contributor

@WilcoFiers
I guess my point was that SVGs can be complex, with many random text elements... charts, graphs, maps, word art, cartoons containing text, etc, etc. SVGs can be - and often are - marked up as role="img". Naming of SVGs (or any img, whether or not it contains an SVG) needs to be a deliberate consideration by the author, and not just guessed by the UA based on text content. So the spec should not recommend that img be named from content. If a user agent or AT wants to use text content as a fallback, that is up to them. However, validators should continue to flag missing names on img.

@scottaohara
Copy link
Member

How is it relevant to this?

seems relevant since if it had a role=img it'd get a poor accessible name, as Carolyn describes. If it did have a <title> would it then be expected to provide the name to the image/svg, or would it become part of the image's name from child elements?

@WilcoFiers
Copy link
Contributor Author

If an svg with role=img has both a <title> and a <text> node, the title would be the accessible name, the text would not be included. This is because accName does not get to the "name from content" step if there is a native element or attribute that provides an accessible name, which <title> is for <svg>.

@carmacleod is the point of what you're suggesting then to ensure that that svg is flagged as having invalid ARIA because img requires an accessible name?

@carmacleod
Copy link
Contributor

carmacleod commented Nov 4, 2020

@carmacleod is the point of what you're suggesting then to ensure that that svg is flagged as having invalid ARIA because img requires an accessible name?

Yes.

[Edit: Actually, not quite sure what you mean by "flagged as having invalid ARIA"? The role="img" is valid on svg (see svg in the SVG Role Mapping Table). It's just the missing name that would be invalid.]

@pkra pkra added this to the ARIA 1.3 milestone Jun 27, 2023
@pkra pkra added the feature may add new concept(s) to ARIA which will require implementations or APG changes label Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature may add new concept(s) to ARIA which will require implementations or APG changes
Projects
None yet
Development

No branches or pull requests

5 participants