Use Grid to lay out swatch color picker
Actual behavior:
The buttons are wrapped in a table element. Tables should not be used for layout.

Expected behavior:
The markup could be for example a div using flex or grid display.
Priorities and help requested:
Requested priority: Low
Grid support in IE11 is a little rough. It'd take a lot of code to layout an indefinitely large list of swatches. Maybe if we finish the #5418 we'd be able to apply a grid system that was grid support aware.
I agree though that this isn't tabular data and a style refactor wouldn't hurt.
@betrue-final-final do you have any background on why a table was used here? Should we consider this a bug?
I have no idea what they did in code, but a grid like this should be navigated via arrows.
@jspurlin Any thoughts?
Is this actually causing a bug with screen reading? Or, is this just code cleanup?
The grid does allow for arrow key navigation. A grid must contain rows which must contains gridcells so we needed to dom structure to put the correct roles and a table made sense to use
Yeah, I believe this is in the same case as the calendar. A grid of elements that can be navigated through via keyboard. I believe the 'not using grid for layout' probably refers more to page layout, and not interactable elements.
@Rafaelki do you feel these reasons are sufficient to keep the control as is? If we had better support for css grid, I think we could make an argument for that, but any other layout approach would probably introduce more issues....and would also put in question our DOM choice for things like calendar.
The existing control seems to make sense to me, but @jamesedjac might know more.
As you said this isn't tabular data so it is incorrect for me. A calendar can be considered tabular data. I understand the grid layout brings problems in ie11. What about display:flex or even display:table?
@Rafaelki is there a screen reader issue, a navigation issue, keyboarding, high contrast bug, or are you just saying when you f12 the dom and see a table you don't like it?
Just trying to understand.
lol! that question is priceless, especially the original one! I guess I when I press f12 and see that table I don't like it. Do you guys like it? Do you think it is SEMANTICally correct?
Well.. I mean... seeing a table in this component does not keep me up at night, like many of the other issues do. :)
My thought is that even a DIV itself is not "semantically correct", really. It represents a "box" which seems pretty meaningless. Well... table cells are also boxes. Does it make the experience any different? I think this is really why role and other aria related attributes exist; to help provide meaning to otherwise meaningless things.
A button, rendered as a span, is not semantically correct. But it's necessary to achieve some goal. Because, for example, buttons can't be nested, and sometimes you do need to nest clickable areas.
Tables represent a grid of information. They have a layout behavior as well that does not exist by default in divs, without styling.
So my perception is... if a user uses a component, and it looks correct, and a blind user uses a screen reader and it reads correct, and you can see it in high contrast, and keyboarding works correctly and RTL looks right... what exactly is wrong with using a DIV vs a SPAN vs BUTTON for something clickable assuming it has the right roles and such? Likewise goes for TABLE vs DIV with styling. It just seems like religious wars to me which achieve nothing.
Clearly we want best practices in the code, and I would not object to changing this out. I was really just trying to understand if we are missing some key thing or if it's just code smell :)
If you feel strongly enough here to change it out to use something than a table, would you be willing to make a PR? We take contributions! :) Otherwise I'd prefer to close, as we need to dig deep into many of the other issues and it doesn't meet the bar and we have limited resources.
Well... a div does NOT represent a box. The div element is a non-semantic element. If you want to use a semantic element probably UL is the one to choose, as it looks to me like a list of colours.
NOTE that I DIDN'T say that you HAVE TO use semantic elements, but when you use them you should not choose the wrong ones.
In your example, using a div or span as a button is semantically void but is not wrong because div and span are non-semantic elements ie. they don't give you any information. But using for example p, table or article for a button is wrong because they give you a misleading information.
I don't think is a religious war or about personal preferences, this is HTML 101, there are rules about this...
blocked waiting for #5418 to be done
Throwing my $0.02 in here.
Saying "we have bigger fish to fry" is an acceptable response - we accept that you have limited resources and not everything is high priority.
But saying that someone asking you to use semantically correct markup - and specifically to stop using a table to achieve a grid layout is "like religious wars" is way out of line - and completely missing the point!
Tables are for "tabular data" .. which have a Column and/or Row references. A calendar is an excellent example .. where the Column and Row references typically represent things like Day and Week respectively (through appropriate < th > elements).
Simply "I would like to display a list of things so that it looks like it is in a grid" is not a good enough reason to use a < table > element. I would probably pick an unordered list .. as it represents a "list of values" to pick from - but I'm sure there are plenty more "accessible grid" options to pick from out there (from floated divs, to CSS grids, and many more besides).
Semantically speaking you are presenting a picker. It is a list of options - each one representing a singular value. Rendering a "grid" is only useful for sighted users as it "looks pretty" on the page and takes up less space.
For a screen-reader this is not the same. The main reason is because a screen reader will call out the row/column identifier for each "cell" (both when reading the page .. and when navigating through the options) - for a grid of colours the "context" of a given cell in the table is meaningless.
Assuming you have a two-by-two "grid" of colours (Red, Green, Yellow, Blue), a Screen Reader will typically read out the following: "Table with two rows and two columns, row one, column one, red, column two green, row two, column one, yellow, column two, blue."
In that instance the "row" and "column" references are meaningless. They don't add anything to the usability of the page, they just get in the way.
In comparison an unordered list would read something like "list of four items, Red, Green, Yellow, Blue, list end".
This is much more concise, meaningful and semantically accurate.
It is also worth considering that many screen reader specific web browsers have short-cuts for "list the tables on the page" (same as it does for links, buttons, headings, lists and other semantic markup values) .. in this case you will be returning what is effectively a "list of values" as a "table of data" - this is also incorrect.
The same goes for other such behaviour - for example the comment above that:
"A button, rendered as a span, is not semantically correct. But it's necessary to achieve some goal."
No .. it isn't. You should not be using a < span > with a click event or similar trigger. You should be using a button, input or anchor - because a screen-reader won't be able to tell the user that your "span" is interactive - and asking the page to "list all buttons" or "list all links" will completely ignore your "< span >" with a click event attached.
I'm not going to wax lyrical about this much further, but can I suggest that "religious war" comments are kept well and truly out of this type of dicsussion, and I suggest that if the developers in question are interested in screen reader issues then they actually try testing with one? They are free to download and really quite easy to use!
Two web references below which might be useful - and perhaps inform the discussion further:
W3C Web Accessibility Initiative on "Tables" https://www.w3.org/WAI/tutorials/tables/
Data table with role="grid" test results with screen readers https://www.powermapper.com/tests/screen-readers/tables/table-role-grid/
A span with role=button should read correctly as a button. The other nuance however is that keyboarding is different between a button and a span and needs to be handled correctly.
I do apologize if any of my comments came off in any other way than to dig into what is wrong and why. I don’t think I mentioned religious wars but i did ask the clarifying question about whether it was a code smell vs legitimately broken thing.
Again my comments were not against the idea of cleaning up the markup. We want every control to exhibit correctness in markup.
The component was added (i believe) by @jspurlin. I can ping him to respond to this one.
@MartinHatch, @dzearing is correct we used role="grid" specifically to convey to AT users that the options are laid out in two dimensions so that they can navigate perceive/navigate the content as effectively as possible. For example, from the aria spec for grid: [grid is] A composite widget containing a collection of one or more rows with one or more cells where some or all cells in the grid are focusable by using methods of two-dimensional navigation, such as directional arrow keys.
I think the message here is to not use a table (meaning semantically a grid of data) for a thing which is not a grid of data. It isn't necessarily about what the reader reads.
It sounds like @joschect will be in this area shortly to help clean things up, and I've given him a heads up to help clean up the markup here.
Is the complaint about using the <table> element? I get the principal of why you shouldn't use the <table> element for a non-grid of data, but you'll need almost the same number of elements (except for maybe the <tbody> and <td> elements) to be able to properly represent the grid, rows, and gridcells. Additionally, changing the role of the elements make it so that the semantic meaning of the elements change
@jspurlin Yes, my complain is about using the <table> element, as I think it is clear in the issue description (note that the title of the issue has been replaced by someone else).
You are right about the role="grid" and about the number of elements (I was not aware the aim here was to save elements), so my understanding is that it will straightforward just to replace table/tr/td for divs and use the style display:table (as I suggested in a previous comment). Again I think it is better if it is semantically void than semantically misleading.
@dzearing how can you say you didn't mention religious wars? you only need to scroll a bit to see your own comment... It is in the same comment where you said that divs and tds represent boxes!