-
Notifications
You must be signed in to change notification settings - Fork 676
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
[css-grid] Masonry layout in CSS Grid 3 has potential to cause accessibility problems with reading order. #5675
Comments
But speech order not matching visual order is already happening in Grid level 1. Can you clarify what's different with masonry?
Would it? From https://drafts.csswg.org/css-grid-1/#source-independence
|
at the moment in Grid, yes you can move things out of order, however (other than dense packing) auto-placement doesn't do that. So where you have moved things out of order you should know you have done it. The fact that people are building grid tools that move things out of order and don't warn the user is a different though related subject. With masonry we give people a really compelling layout method which is likely to cause this problem without the author actively doing it. It also might be tricky to test as at one breakpoint the reordering might not be too bad, and at another awful. This was brought up at the CSSWG face to face where masonry was first proposed. It does feel that we are adding more layout methods that create this reordering issue without trying to solve the issue in a way that would help this, but also other reordering problems. |
See also : https://rachelandrew.co.uk/archives/2019/06/04/grid-content-re-ordering-and-accessibility/ (predates this masonry spec). |
If you look again at my first sentence, you'll see my concern is not how a screen reader will relay the information.
I think @rachelandrew nailed my biggest concern. As the layout adjusts to content, viewport, or any other factor, the visual reading flow as well as the tab order are going to create problems for other sets of disabled users.
Using positive We need a method though that will ensure that users will be able to read things in their proper comprehension order and that tab order matches visual order. A thought here could be "item priority" which defaults to code order (or no priority), while other options allow you to specify any number of blocks to accept a value that then makes sure the tab order changes to match the visual. |
I slightly disagree with the premise of this issue. You really shouldn't use (default) masonry layout in the first place if the item placement matters to the semantic meaning of the content. So I think the original example doesn't make sense, for anyone, sighted or not. (There is however I agree with the later points though, that taking input both visually and from a screen reader simultaneously could be slightly disorienting since the order may not completely match (they are typically somewhat close for default masonry layout though). This is a general problem with Grid and other layout that can place boxes in arbitrary positions. I don't think adding more HTML/CSS features and relying on authors to use those features is a tenable solution. For two major reasons: 1, authors rarely take the time to do that extra work, and 2, predicting the visual layout is very hard in responsive designs. Instead, I think it should be solved by browser implementations and AT. For example, a browser could provide the visual box order of a Grid container (masonry or regular) to an AT. This could be used by the AT to offer DOM order or visual order as an option to the user. Visual order might be preferred by users that consume both visual and screen reader information simultaneously. Browsers need to have a concept of visual order anyway to implement selection in a way that makes sense. For example, selecting text with the mouse from an item in the top-left corner of a grid into its neighboring item on the right should really just select the text in those two items, not the entire DOM range in-between. (We don't implement that in Firefox yet, but we intend to.) |
As far as keyboard navigation is concerned, https://drafts.csswg.org/css-nav-1/ is an attempt to cope with the fact that there is no perfect answer to ordering of content laid out in a 2D space, and therefore navigation should itself be available in 2D. |
I want to remind folks that there are people who are disabled yet use no AT, so we need to consider that when writing specifications. Like previously said, we have non-visual screen reader users, visual screen reader users, and ZoomText (and similar magnifiers) users. But we also have neuro-divergent users who may use no AT. We have low-vision users whose "AT" is just reducing the screen or viewport's resolution or increasing font size. And there are people who are keyboard only who actually may have no disability or a physical one which doesn't require AT. There seems to be a glossing over some of these types when trying to address the concern I raised.
Completely agree, but we have to know authors will use it inappropriately unless something is enacted to prevent or work around these issues. Leaving it to authors will bring interfaces that have a11y problems.
I can agree with this. I'm looking for solutions that don't really leave the potential problems in the hands of authors anyway. I want them to be able to use these grid features without accidentally making an inaccessible experience just because they misunderstood which property to use when. This happens enough with the HTML we have.
I took some more time reviewing that today as it didn't really sink in yesterday. I do think this can answer the problem, however we are relying on the following:
I think CSS-Grid in general (and especially for masonry) needs to have a dependency on CSS-Nav where when grid is implemented, the parent grid is the spatial navigation container and default spatial navigation properties are implemented on the objects inside. This could prevent all my concerns, but I realize CSS-Grid is in the wild now and adding a dependency to it could have significant unexpected impacts to those sites using grid. WCAG could add a best practice around this, but now we are depending on authors to do the work to know the the two specs and make sure they follow the guidelines for accessibility. I'm aiming for as close to preventing inaccessible experiences by default as possible. |
Playing catch-up…
I have seen it used for cards, making the entire box an interactive thing.
This is a huge point — the few cases I have seen involve devs testing at up to 3 arbitrary breakpoints (iPhone, iPad, their own desktop).
But people will. We have lots of evidence telling us devs will use whatever achieves their visual layout objective regardless of intent (
That draft does not address the challenge today and should not be considered a fix. If it happens, that could be ace since it could address years of issues with floats, absolute position,
Big +1. I also agree that throwing more features at this will not solve it. Here's what we can posit based on experience:
Perhaps a place to address this is their tooling. I know many developers rely on the grid (or What do you think about browser developer tools warning devs when their layouts break some basic flow patterns? The simplest approach (IMO) is to draw arrows from box to box, and (for LTR languages) use that visualization to highlight problems when the arrow goes both upward and to the left. I have images demonstrating these arrows where I first proposed the reading / source order tool: Chromium now has a reading order viewer built in, but it does not use arrows to make breaks in the flow more obvious. This feature would need to built by the browser as it builds support for masonry to be most effective. |
I'm all for tools that help developers build more accessible sites. Your concept is interesting, but I'm not sure it well it will delivery the message. I think the best thing would be to make sure that we include clear examples and demos of how to do it right along with warnings on the impacts of doing it wrong. With clear instructions, then people working on tools and browsers can build ways to clearly demonstrate this and hopefully we can educate devs. |
Agreed. I was not clear that my suggestion was in addition to this. Partly based on experience with devs today where they do not read the spec or even MDN (so they cannot get the message), they just read an article at popular dev site. I feel the accessibility challenges need to be raised in more than one place. Which makes my suggestion outside the scope of the CSSWG, I know. |
How is this issue solved already by big players in the masonry space, e.g. Pinterest? |
I think this issue can be closed. Masonry presents no new problems that aren't already present with Grid's arbitrary reordering capability, so any solutions that we come up with for either will fix both. And we have indeed come up with such a solution, via Tho also, (Note that the example in the OP showing a confusing order won't happen by default; it requires "over" to have been explicitly placed there, and possibly "the lazy" too. The default placement will instead make the last row |
Tab and I drafted a new accessibility and reordering section to address some of the considerations here: Let us know if you have any suggestions for improvement! |
I appreciate the addition of that section. I think it helps show the risk, especially since as written (including the example) it essentially identifies a probable WCAG SC 1.3.2 : Meaningful Sequence failure. I say probable because an author may only use masonry for a simple picture gallery versus content where the order matters (though that is not my experience so far, as noted above). |
@fantasai As the |
Assuming all authors code their masonry grid in a valid reading order, screen reader user who are non-visual will have no problem with it. But once we introduce visual screen reader users, low vision with no assistance, magnification software users, and users with cognitive problems, the layout begins to cause problems in focus order and reading order.
If we have
<div>
<item>The quick</item>
<item>brown fox</item>
<item>jumped</item>
<item>over</item>
<item>the lazy</item>
<item>dog</item>
</div>
The screen reader user will hear "the quick brown fox jumped over the lazy dog." When we add the CSS and visual layout, the reading order could be realistically be:
Image description: 6 blocks laid out using masonry reads, "The quick brown fox jumped dog over the lazy"
If these have active controls, the focus order would match the visual as well. I think using a simple sentence quickly demonstrates the damage and problems that could happen for users with cognitive issues, zoom users, and the dissonance a sighted screen reader user would encounter. This gets even more amplified if the author improperly uses tabindex set to a positive number.
I'm not clear on a solution. But I am clear that while the masonry may initially be targeted for photos and other visual pages, we have to expect it to be used by others for different things. If the individual items are standalone, like articles in a newspaper, then this isn't an issue, but we need to provide a way to control the focus/reading order to make sure the content doesn't become inaccessible.
The text was updated successfully, but these errors were encountered: