Repository navigation
Add table caption validation check for core/table block - #29
huzaifaalmesbah wants to merge 2 commits into
Conversation
|
Thanks for the contribution @huzaifaalmesbah, the implementation looks solid and this is almost ready to merge. Before we do, I think we need alignment with the rest of the Accessibility Team on our approach to default severity for non-mandatory accessibility concerns. Table captions aren't required by WCAG (H39 is a sufficient technique for 1.3.1, not a mandatory one), so my take is this should default to Let's get that settled as a team before merging so we're consistent going forward. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
- Register check_table_caption under core/table in Core_Block_Validation_Rules at warning level. - Implement validation in core-block-rules/table.ts to check for non-empty caption text (WCAG 1.3.1). Closes WordPress#28
Table captions are a sufficient technique (H39) for WCAG 1.3.1 rather than a requirement, so leave the check disabled by default and let site owners enable it in Validation settings. Also treat captions containing only non-breaking spaces as empty.
763a296 to
a257d82
Compare
|
Thanks @troychaplin! That makes sense — since H39 is a sufficient technique rather than a requirement, I've changed the default level to Happy to adjust if the team settles on a different default policy. |
What?
Closes #28
This PR adds a new WCAG-oriented validation check
check_table_captionfor thecore/tableblock in the Core block accessibility rules module.Why?
Under WCAG 1.3.1 (Info and Relationships), Technique H39 recommends that data tables provide an associated
<caption>to help screen reader users identify the topic or purpose of the table without reading through each cell. Currently, only header rows are validated (check_table_headers).Because H39 is a sufficient technique rather than a WCAG requirement, the check is registered with a default level of
none(disabled). Site owners who want to encourage captions can enable it as awarningorerrorin Validation settings.How?
check_table_captionundercore/tableinCore_Block_Validation_Rules.phpatlevel: none.src/editor/core-block-rules/table.tsto inspectattributes.caption, stripping HTML, whitespace and non-breaking spaces to verify meaningful content exists.warningorerror.Testing Instructions
/table) with headers and some data cells.validation-api-block-warning), and the sidebar shows:Consider adding a caption to this table.(core/table)Testing Instructions for Keyboard
With the check set to Warning as in step 1 above:
Tab)./table).Tabto navigate through cells without filling the caption.Tab/Shift+Tabto reach the top bar and activate the Validation sidebar button.Screenshots or screencast
Screenshots show the check with its severity set to Warning.
Use of AI Tools
AI assistance: Yes
Tool(s): Google Antigravity
Used for: Implementation skeleton, TypeScript/PHP integration, local testing in browser, and PR formatting. Reviewed and verified locally.
Tool(s): Claude Code
Used for: Rebasing on
mainand applying review feedback (default levelnone, non-breaking space handling). Reviewed before pushing.