Repository navigation
feat: Tables a11y (BLO-1230) (BLO-1231) - #3215
matthewlipski wants to merge 11 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
nperez0111
left a comment
There was a problem hiding this comment.
I'm confused on the approach for this. Is is that we need to do a bunch of calculations to get the right attribute values? Why are we not just adding new attributes to the nodes that we need. Tables are especially easy to do this from since they are transformed anyway for the blocknote representation
| } | ||
| // Mark the cell as a header if it is a tableHeader node. | ||
| headerMatrix[rowIndex][cellIndex] = cellNode.type.name === "tableHeader"; | ||
| row.cells = rowNode.content.content.map((cellNode) => { |
There was a problem hiding this comment.
I'm confused why this changed
There was a problem hiding this comment.
This and the above change you commented on fix a bug with converting to/from TipTap nodes. Check commit c141d42 which adds a test case for it. When either of the changes is reverted, the test fails on round trip.
| applyHeaderScope, | ||
| } from "./cellAttributes.js"; | ||
|
|
||
| export function TableAccessibilityPlugin() { |
There was a problem hiding this comment.
I'm confused on why we are doing this via decorations and serializers, why are we not just adding the attributes to the table cells/headers
There was a problem hiding this comment.
To get the value for headers we need the position of the cell, so we need to use a node view. I tried doing that instead of using decorations but settled on decorations because it was more readable basically.
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
@blocknote/xl-typst-exporter
commit: |
|
Hello @matthewlipski ! thank you for your work ! ( this is Cyril, working on LaSuite accessibility ) I went through several cases in the editor on the current branch. Header relationships look correct, including for merged cells. A header row gets scope="col", a header column gets scope="row", and data cells get a headers attribute pointing at the matching ids. A cell merged under two columns lists both ids. A merged header keeps a single id, shared by the cells it covers. Merging a TH with a TD does not drop scope. Copying the table produces distinct ids, with no null. The PR is still under review, so this only covers the branch as it is now. Another pass will be needed once the review changes land ;) . One separate limitation, outside these issues: there is no keyboard path to open the row or column handles, or to select several cells and merge them. Those actions still require the mouse. |
|
Thanks @Ovgodd ! I'll double check to see if there are any edge cases with merged cells where headers don't get assigned properly. As for the table handles, I'll be doing a deep dive soon on keyboard accessibility for all UI elements, so also including things like the side menu, link toolbar, and revisiting the formatting toolbar. I think we will be taking a similar approach to CKEditor with keyboard shortcuts that move focus to these UI elements. Out of scope for this PR ofc but would be great to get your thoughts:) |
|
Ok I have indeed found a case where the added attributes change the a11y tree and screen reader output. Added a test which I've checked fails without the changes and passes with. |
Summary
This PR adds some additional HTML attributes to tables:
idscope(determines whether header is for a row or column)headers(determines which headers the cell is under)They are not required by WCAG guidelines and so are not caught in axe scans, but make the relationships between cells and headers more explicit, especially when they span multiple rows/columns.
This is implemented using decorations. Serializing to HTML has additional logic to apply the attributes as decorations can't be applied.
Closes #2825
Closes #2826
Rationale
This is an a11y improvement.
Changes
TableAccessibilityPluginto apply cell & header decorationsImpact
N/A
Testing
Updated table format conversion snapshots and added ARIA test to verify that the added props change the a11y tree.
Screenshots/Video
N/A
Checklist
Additional Notes
N/A