Hi,

As the generated markup is a table, would it be possible to add some attributes for the fields (like alt & title for the images), so people can enter a caption for the table as well as a longdesc (for accessibility). I'd like to stress that IMHO, caption is more important than longdesc for sites that don't bother with accessibility, so if you want me to create two distinct issues, just let me know.
The module is really great, and I think it would be a nice addition to be able to at least fill the caption.

Comments

Everett Zufelt’s picture

Title: Caption and longdesc attributes » Allow ability to set table caption

I have not used this module, but I do think it would be useful for the ability to add a table caption to be introduced.

Regarding alt / longdesc, these really only apply to images. If you can give more details about how you envision these being introduced to this module I can provide some feedback.

simon georges’s picture

Title: Allow ability to set table caption » Allow ability to set table caption and summary

Hmmm, sorry, the longdesc is for images, for tables it's "summary".
I was thinking about adding one text field for the caption, and a textarea for the summary, both not mandatory, and, if present, rendered by the formatter (eventually prepare a formatter with / without caption).
I've not studied the hook for D7 yet, so I don't know if you have to alter at the field and/or widget level. I'll take a look at this when I have some time.

lsolesen’s picture

@Simon Georges --> you ever got around to having a look at this issue?

simon georges’s picture

@Isolesen, my client didn't need it, so I (shame on me) didn't do anything on the subject :-(

btopro’s picture

Version: 7.x-2.0-beta4 » 7.x-2.x-dev
Category: feature » bug
Status: Active » Needs review
StatusFileSize
new4.4 KB

This patch resolves 3 accessibility errors currently with this module.

  1. It adds a caption field per instance of the table field
  2. It adds a summary field per instance of the table field
  3. Table headers have scope="col" added

All three of these improve screenreader support and are requirements of major accessibility standards.

This is rolled against the latest git checkout / dev. Please review this patch and get this pushed through with some priority as accessibility of this module is a major blocker for government and university usage.

btopro’s picture

StatusFileSize
new4.27 KB

Oops, realized I did a checkout of master and not 7.x-2.x for initial patch. This one is rerolled against 7.x-2.x

ItangSanjana’s picture

#6 patched.

tablefield_accessibility-1251738-6.patch:40: trailing whitespace.

Checking patch tablefield.module...
Applied patch tablefield.module cleanly.
warning: 1 line adds whitespace errors.

Everything else OK. TIA

ItangSanjana’s picture

#6 patch.
Invalid argument supplied for foreach() in theme_tablefield_view() (line 872 of /sites/all/modules/tablefield/tablefield.module).
Steps to reproduce:
Leave the header empty and save the node.

zerobyte’s picture

@iS, does the bug you're referring to only apply if the table header is left empty?

ItangSanjana’s picture

@zerobyte, yes it does. Not empty no problem.

mastoll’s picture

Issue summary: View changes

Yikes.
Any resolution on this? It would be nice to be able to leave the headers empty.

btopro’s picture

How do you make a table without headings using this? Isn't that just an empty table?

mastoll’s picture

@btopro, if I understand your question correctly, you leave the first row blank, fill in the rest of the rows.

mgifford’s picture

There are now examples in D8 Core of how to do this.

ItangSanjana’s picture

StatusFileSize
new4.29 KB

Hi, this patch fixed #8 issue. Please review.

btopro’s picture

Looks fine to me; only difference from #8 is checking for the header property prior to looping through instead of the other way around; this should resolve the issue expressed with #8

mgifford’s picture

Title: Allow ability to set table caption and summary » Allow ability to set table caption and details
Status: Needs review » Needs work

Summary has been depreciated, worth checking out #843708: Add option to set caption & remove summary in the html table (Accessibility). Changing title.

sjbassett’s picture

Status: Needs work » Needs review
Issue tags: +a11y
StatusFileSize
new4.56 KB

Great to see this change being added to this module. I wanted to suggest some changes that needs a bit of review. The changes involve better descriptions for the accessibility fields added to the widget.

Provide a brief description of the data the table contains, this is associated to the table and helps Assistive Technology, like screen readers, better describe your tables content.

The summary attribute helps describe the structure of complex tables. It is better to have simple tables, but this attribute can help when that is not possible.

See the new Patch #18

btopro’s picture

@sjbassett can you rework the patch based on what @mgifford said in #17 . Summary is no longer a thing from my reading so we shouldn't keep pushing it in A11Y patches. Caption should be good enough for making the table accessible. Aria I assume can be added via other projects / themes if people want to add even more detail.

sjbassett’s picture

@btopro Good to hear that we are removing summary, it isn't very helpful. I will just remove that then and reroll the patch in a second.

sjbassett’s picture

So I am guessing that we would want to use something similar to this type of markup to provide better semantic for describing the data:

<table>
<caption>
  Population of Cities in California in 2010
  <details>
   Populations of the largest cities in California listed from largest to smallest, with recorded population in the right column.
  </details>
</caption>
...
</table>
sjbassett’s picture

The browser support for the details element is pretty lousy, see MDN Browerser Support for <details> element.

I think a simple addition of the caption field would be the best solution for this module, less changes and flexible enough to add further changes in the future.

sjbassett’s picture

Title: Allow ability to set table caption and details » Allow ability to set table caption
Issue summary: View changes
StatusFileSize
new3.38 KB

Simplified the patch to include just the caption element since browser support is great for the <details> element, changing the title to "Allow ability to set table caption"

btopro’s picture

Looks good aside from small typo in comments + // check for table captionwq. Got any testers to push this forward?

mgifford’s picture

So yes, Details look bad but they seem to basically work fine in D8.
SUMMARY is obsolete in HTML5 and this is the recommendation for making accessible tables Section 4.9.1.1 Techniques for describing tables

Other sources:

sjbassett’s picture

@mgifford

I am in full support of using new elements to help improve the semantics here, but for a bit of pragmatism, I think we should make a solid change just for caption, then add a new issue on handling the nested details within the caption.

mgifford’s picture

Yup, <caption> is solid.

sjbassett’s picture

liam morland’s picture

Issue tags: -a11y +Accessibility
mgifford’s picture

Some overlap...

gremy’s picture

StatusFileSize
new3.31 KB

Re-rolled the patch so that it applies cleanly on the latest version of tablefield.

jenlampton’s picture

StatusFileSize
new3.19 KB

This new version of the patch fixes some PHP syntax errors, capitalization, and spacing.

Also, I cleaned up the text on the Caption field. Before the label was Caption and the description was Provide a brief description of the data the table contains, this is associated to the table and helps Assitive Technology, like screen readers, better describe your tables content..

Now, the label is Table description and the description is This brief caption will be associated with the table and will help Assitive Technology, like screen readers, better describe the content within.

jenlampton’s picture

StatusFileSize
new3.53 KB

Rerolled again with a little more cleanup and to prevent another PHP notice.

kmcculloch’s picture

StatusFileSize
new4.24 KB

The patch at #33 passes a "caption" argument to theme_table whether the user provided a caption or not. If the user didn't enter a value this results in an empty caption tag in the markup. I refactored theme_tablefield_view() to prevent this.

This patch was generated against commit 90f2bd5 in the 7.x-2.x-dev branch.

jenlampton’s picture

Status: Needs review » Reviewed & tested by the community

This looks great now, thanks for the improvement @kmcculloch!

  • jenlampton committed 7aeb4b5 on 7.x-2.x
    Issue #1251738 by kmcculloch: Allow ability to set table caption.
    
jenlampton’s picture

Status: Reviewed & tested by the community » Fixed

This feature will be in the next release.

  • jenlampton committed 5817cd8 on 7.x-2.x
    Issue #1251738 by sjbassett, btopro, ItangSanjana, gremy, kmcculloch:...
jenlampton’s picture

Status: Fixed » Needs work

Whoops, it looks like this actually contains a little XSS hole. Let's see if I can fix it up real quick.

  • jenlampton committed 7a33846 on 7.x-2.x
    Revert "Issue #1251738 by sjbassett, btopro, ItangSanjana, gremy,...

  • jenlampton committed 299246c on 7.x-2.x
    Issue #1251738 by sjbassett, btopro, ItangSanjana, gremy, kmcculloch,...
jenlampton’s picture

Status: Needs work » Fixed

I added two calls to check_plain() where the caption was passed into the theme layer, and where it was displayed in the form. If the caption needs to contain markup (or something other than plain text) let's open a follow-up issue. I think this is a great improvement to have the table caption, so I'd like to get this into the next release. Marking fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.