My team and I are building a web-app for a customer who has requested custom functionality pertaining to data-tables: upon clicking the header of a given table column, the table then becomes sorted based on that column. This functionality is already implemented.
However, an important stipulation of the contract is compliance with WCAG 2.1 accessibility standards. Aside from within tables, we have aria labels in all the right places, but it's unclear how we should go about making this custom table behavior more accessible-- particularly for screen-reading tech. As of now, the table header cells themselves have event-handlers for clicks to trigger the functionality, but no semantic <button>s are involved in this process, which is where things start to feel a little wrong for me.
The table header cells are also focusable, so that users can use Enter or Spacebar to toggle the functionality that way. How should we handle communicating this behavior to the user, especially those using screen-readers? Since this functionality is not typical of what is otherwise a fairly standard table, guidelines and requirements from WCAG and other sources are unclear.
I apologize, but I am unable to provide a screenshot or code snippet due to the sensitive and proprietary nature of the content.
For any table that is readonly and also is meant not to be sorted etc. standard HTML tables should be used.
In your case please use the design pattern grid from the ARIA 1.1 guideline (chapter 3.12 under this link https://www.w3.org/TR/wai-aria-practices/#grid)
Your customer should familiarize himself about the keyboard commands ARIA declares for grids. Manipulating theese keys will mean much work to you and irritating the screen reader user and hurt WCAG.
Here are two decent examples of accessible sortable tables:
https://assets.cms.gov/resources/framework/2.0/Pages/datatables.html
https://adrianroselli.com/2021/04/sortable-table-columns.html
The first one is a little too wordy with it's announcement to screen readers and could be shortened up for a better user experience and the second one is a little too terse with just saying "title button". We need a Goldilocks example between the two but both examples show how to use a <button> in the table header and the use of aria-sort.
I didn't hear anything in your OP that would indicate that a grid should be used. Note that the first sentence in the grid definition says that a 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." In other words, if the user will be able to navigate the table using the up/down/left/right arrow keys (as if you're navigating through a spreadsheet), then a grid is appropriate. But if you have a "normal" table that does not allow navigating cell by cell, then a standard <table> can be used. Just add buttons to your column headings (<th>) that allow the table to be sorted.
Related
I am being asked to put checkboxes on a webpage that perform no resolution, in that they simply exist to be checked in the form of a checklist that could be printed. There would be no form submission, no buttons, no popups or collapses, and no actions resulting in the checking of the boxes.
I believe this would be against the grain for UX and potentially against accessibility rules. Are there any rules I can reference in the WCAG guidelines that would back me up?
A couple of things to consider:
If the checkboxes perform a function in that they allow the user to check off which items are completed, then they are there for a reason but it's a question of whether their purpose has been clearly communicated.
From what you describe, non-accessibility users would be getting the same non-functioning checkboxes that accessibility users get, so accessibility is less of a consideration here than UX design. Accessibility is concerned with providing an equivalent user experience and conveying the same information for assistive technology users as for non-AT users, so quoting a WCAG guideline won't really help if the design problem affects both AT and non-AT users.
With that in mind, the WCAG guideline that seems most relevant to me is 1.3.1 - Info and relationships. This guideline deals with preserving the relationship between page information and the semantic structure or layout of a page, so that the way a page is structured (including the components used) doesn't convey different things to AT and non-AT users.
A common failure of WCAG 1.3.1 would be something like using headings for presentational purposes, but it can apply to any component which has a semantic meaning that is different from the presentational meaning. In your case, using checkboxes as a presentational device could fall under that type of failure. See here: https://www.w3.org/WAI/WCAG21/Techniques/failures/F43
The situation is a bit unclear. The checkboxes are there to be checked, but there is no action that could result in them being checked. That seems to be a contradiction.
In any case, I believe it causes no accessibility issue to include checkboxes on a web page, regardless of whether they are in a submittable form. There could be good reasons to do so. For example, if there are 10 checkboxes and the instruction tells the user to check no more than 4 of them, a script could enforce that requirement. Whether the purpose is to let the user print the page, or save it as a PDF file, or send a PDF version by email, or think about a topic, checkable checkboxes can be useful, and I know of no basis for an inference that they must be submittable to a server.
I have an existing (search autocomplete) component that needs to be made accessible.
The component consists of a text input, which on input opens a combobox (with data fetched from the server) which shows the data in a grid-like layout with additional information like categories and some visual styling (the icons are purely decoration and can probably be hidden from screen readers). To my understanding, this would be implemented according to this example.
However, the options in the combobox are also grouped by type (eg. "Content", "Categories"), which, in a combobox using a listbox, would be implemented using the 'group' role like in this example. I know this is an editor's draft, but in the spec it is already in the working draft.
Now, is it possible to implement this in an accessible way, having both the grouping (ideally with the grouping semantic available to the screen reader, like with role='group') and the additional information (ideally in gridcells, as in the example)?
Or will I have to resort to hiding either of them, to either using a listbox and hiding the additional information from the screen reader, or by using a grid and having either no grouping or just rows that are non-interactive and have no semantic meaning?
Note: I have no influence over the styling/layout, only what is presented to the screen reader. I am aware that this is not the most ideal starting point.
Can someone advise me if there is a specific WCAG 2.1 failure when buttons are used as links. Same question vice versa. Links as buttons.
I have a site i am working on where by design there are links that appear the same as the buttons do.
So you may have buttons <button> like:
Edit details - which takes you to a new page where you can edit items in the page where the "edit details resides".
Continue - a button that takes you to the next page in a series of pages.
But then have links <a> which appear as buttons, so the same style, but they are labelled select, select and selected and these are a product type, so do not link anywhere.
Another example is the back link is a button<button> but looks like a link (text with underlined style)!
I know that this behavior confuses voice recognition as the user says click link or click buttonand not all objects get flagged that appear the same.
My question is does this fail WCAG2.1 specifically? Would this fall under 4.1.2 Name, Role, Value?
The 4.1.2: Name, Role, Value undestanding addresses the case of elements having different role than usual.
If custom controls are created, however, or interface elements are programmed (in code or script) to have a different role and/or function than usual, then additional measures need to be taken to ensure that the controls provide important information to assistive technologies and allow themselves to be controlled by assistive technologies.
As Adam already cited, "additional measures need to be taken to ensure that the controls provide important information to assistive technologies and allow themselves to be controlled by assistive technologies". So yes, this fails WCAG 2.1, unless you take measures to ensure that your button-links and link-buttons really work as they are supposed to for example that a <a role="button" […] can be triggered using the Space key.
If you really have accessibility in mind, don't mix <button> and <a> elements up. Not even if you think you are smart and add role="button" to a link or role="link to a button. You would have to do more than that to make them behave like each other (see MDN about the button role).
And even then you should consider this: links are for navigation, buttons for performing actions. If you have a navigational element that looks like a button, its behavior might be confusing (even if it has no role="button" attribute). Also note that the default value for a button's type attribute is submit ("The missing value default and invalid value default are the Submit Button state.").
Web accessibility should encompass all disabilities that affect access to the Web and there are a lot of possible disabilities – and having one disability does not necessarily mean a person has no other disabilities.
The easiest step of making your website more accessible is to stick to the standards. Don't change an element's behavior unless you really have to (and even then: do you really have to?).
Update: General comment about WCAG and accessibility:
Web accessibility is also not just about simply conforming to guidelines like the WCAG. Even the WCAG itself does not claim that a website will be 100% accessible when conforming to it:
Note that even content that conforms at the highest level (AAA) will not be accessible to individuals with all types, degrees, or combinations of disability, particularly in the cognitive language and learning areas. Authors are encouraged to consider the full range of techniques, including the advisory techniques, as well as to seek relevant advice about current best practice to ensure that Web content is accessible, as far as possible, to this community.
Update: Examples of possible violations of WCAG 2.1 (with room for interpretation though)
Just letting links look like buttons and nothing could be failing:
Guideline 3.2 Predictable in general ("Make Web pages appear and operate in predictable ways.")
Success Criterion 3.2.4 Consistent Identification (unless all links look like buttons; the only actual success criterion in these examples)
4. Robust in general ("Content must be robust enough that it can be interpreted by by a wide variety of user agents, including assistive technologies." & Guideline 4.1 Compatible "Maximize compatibility with current and future user agents, including assistive technologies." --> you already mentioned voice recognition and the possibility of not being able to target a link because it looks like a button)
Jonathan Pool wrote a blog article about this issue in which he points out another possible violation:
Worst case: A button that takes an irreversible action ("Yes, I confirm that I am waiving my rights.") pretends to be a link, so the user tries to use SPACE or SHIFT-SPACE to scroll the page but unexpectedly presses the button. This, arguably, would violate Web Content Accessibility Guidelines 2.1 Success Criterion 3.3.4.
I have an html table and I want to be able to hide and show columns dynamically (based on certain values on page load). It could be a large number of columns I need to hide.
I was considering taking the values from the columns that I want to be hidden and putting their values in a data- attribute on the <tr> element to and avoid creating dom elements that aren't being shown in the ui. I need the values somewhere because they are used in click events.
Are there any best practices out there that say it is bad to load columns into a table and hide them with say display: none;, or am I just over thinking it and being anal and should just hide them with css?
I'm unsure of any types of practices particularly for this application. Also based on the information given so far.
The way you are doing it is not the best choice of going about this situation. You are taking data and putting them all in their own elements which not only clusters up HTML with unessessary elements (that are always hidden by CSS) but also can be more taxing then it has to on you and your viewers computer.
When you could be using the data attribute this is a great way to keep the information more consolated, less clutter, well organized, easy to read and manage. Also even when a element has the styling display:none it is still using the computer performance to render all of those elements.
You can read this thread that explains: Read More
The following is a fairly typical layout for admin pages (e.g. searching in a database and doing something with the results):
action dropdown
table header row with column names
second table header row with search filters for columns
result rows with a checkbox
search button
The user can set all sorts of filters, search, select some of the results with the checkboxes, then select an action from the dropdown, and the action and the selected row ids will be submitted to some processing script.
There are some basic expectations for such a control:
GET for searches, POST for actions
use the auto-sizing features of HTML tables so that columns can be narrow or wide depending on the content
reasonably cross-browser
I have been looking for a nice technique to achieve this, but everything I can think of seems to have serious disadvantages:
the simplest would be having two forms (a GET form for the search controls and a POST for the checkboxes), but the HTML4 DTD makes that impossible: I can either wrap the whole table in a single form or put separate forms inside every table cell (which is pretty useless).
alternately, I could use a different table element for every row and group them freely into forms, but then the column widths would not match and I would have to set fixed widths. (CSS3 table-* display types lack adequate support.)
HTML5 allows us to place input elements outside forms, and connect them with the form attribute, but that has even less support.
There is an ugly hack involving invalid HTML with forms directly wrapping tr elements, which seems to work but messes up the DOM, confuses Javascript libraries and is not exactly future-safe.
I can wrap the whole table in a single form, and change its method and action dynamically depending on which button was pressed, but that makes me dependent on Javascript; also, I don't want to submit search controls in the POST request and vice versa, it is unnecessary traffic. Also, when there are a lot of result rows, the search request might surpass the URL size limitations (just a few thousand characters in IE) because of all the checkboxes.
I could do the same but disable the unnecessary fields when the user submits the form. Beyond being horribly overcomplicated for such a simple task, this has various usability problems when the request is somehow stopped (e.g. user pressing ESC) and the user is left with a bunch if disabled form fields.
Is there a better solution I am not aware of?
Use AJAX. It allows you to define your own get/post data that is not form-dependent.