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

Improve table caption accessibility #41502

Open
tellthemachines opened this issue Jun 2, 2022 · 6 comments · May be fixed by #41980
Open

Improve table caption accessibility #41502

tellthemachines opened this issue Jun 2, 2022 · 6 comments · May be fixed by #41980
Assignees
Labels
[Block] Table Affects the Table Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress

Comments

@tellthemachines
Copy link
Contributor

What problem does this address?

Table block originally implemented captions as figcaption elements, due to limitations with RichText output discussed here: #15554

These limitations no longer apply, so nothing prevents us from using an actual table caption element instead. This makes tables more accessible for screen readers, as the caption content will be announced at the start of the table.

What is your proposed solution?

Change the table block markup to use caption as first element within the table element, instead of the current figcaption.

Consider adding a default content to the caption, such as we have on Navigation block name: Table 1, Table 2, etc..

@tellthemachines tellthemachines added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Block] Table Affects the Table Block [a11y] Labelling labels Jun 2, 2022
@rianrietveld
Copy link
Member

@tellthemachines thanks so much! One nice discussion and result at the WordCamp Europe contributor day :-)

@Soean
Copy link
Member

Soean commented Jun 2, 2022

I can start working on it. So we want this?

Old:

<figure class="wp-block-table">
    <table>
        <tbody>
            <tr>
                <td>1</td>
                <td>2</td>
            </tr>
            <tr>
                <td>3</td>
                <td>4</td>
            </tr>
        </tbody>
    </table>
    <figcaption>Test</figcaption>
</figure>

New:

<table class="wp-block-table">
    <caption>Test</caption>
    <tbody>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </tbody>
</table>

@rianrietveld
Copy link
Member

@Soean, yes please.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jun 2, 2022
@julezrulez
Copy link

Will caption be optional? Sometimes content writers choose for a heading (h2...h6) just before a table for reasons. What you don't want is double texts (or texts that are read out twice by a screenreader).

@Soean
Copy link
Member

Soean commented Jun 3, 2022

Yes, the caption will be optional

@Soean Soean linked a pull request Jun 27, 2022 that will close this issue
@talldan
Copy link
Contributor

talldan commented Jun 28, 2022

Table block originally implemented captions as figcaption elements, due to limitations with RichText output discussed here: #15554

RichText limitations weren't the only problems, there were a couple of additional bugs:

  • The tab order for a RichText <caption> is incorrect because table caption elements are before the table in the DOM, but the block editor shows it visually after the table.
  • When tested, Voiceover didn't announce RichText caption content correctly when navigating into a table.

It's definitely worth re-testing those two things as there may have been changes in Gutenberg and VO that mean they are no longer issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Table Affects the Table Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress
Projects
None yet
6 participants