-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Table block: Fix semantic structure for screen readers on back-end #54324
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -349,7 +349,7 @@ function TableEdit( { | |
| useEffect( () => { | ||
| if ( hasTableCreated ) { | ||
| tableRef?.current | ||
| ?.querySelector( 'td[contentEditable="true"]' ) | ||
| ?.querySelector( 'td div[contentEditable="true"]' ) | ||
| ?.focus(); | ||
| setHasTableCreated( false ); | ||
| } | ||
|
|
@@ -414,31 +414,33 @@ function TableEdit( { | |
| }, | ||
| columnIndex | ||
| ) => ( | ||
| <RichText | ||
| tagName={ CellTag } | ||
| <CellTag | ||
| key={ columnIndex } | ||
| scope={ CellTag === 'th' ? scope : undefined } | ||
| colSpan={ colspan } | ||
| rowSpan={ rowspan } | ||
| className={ classnames( | ||
| { | ||
| [ `has-text-align-${ align }` ]: align, | ||
| }, | ||
| 'wp-block-table__cell-content' | ||
| ) } | ||
| scope={ CellTag === 'th' ? scope : undefined } | ||
| colSpan={ colspan } | ||
| rowSpan={ rowspan } | ||
| value={ content } | ||
| onChange={ onChange } | ||
| onFocus={ () => { | ||
| setSelectedCell( { | ||
| sectionName: name, | ||
| rowIndex, | ||
| columnIndex, | ||
| type: 'cell', | ||
| } ); | ||
| } } | ||
| aria-label={ cellAriaLabel[ name ] } | ||
| placeholder={ placeholder[ name ] } | ||
| /> | ||
| > | ||
| <RichText | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will likely break visuals but it works due to the cell itself remaining a table cell. The editable content is now done within the cell. This will also likely cause a slightly different back-end vs. the front-end but it isn't up for debate. It simply does not work when you convert a table cell to an editable field. The entire table loses semantic meaning with screen readers.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need role=textbox if it breaks things? Isn't contenteditable enough?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ellatrix With my changes, it comes with 2 bonuses.
All in all, a big win. |
||
| value={ content } | ||
| onChange={ onChange } | ||
| onFocus={ () => { | ||
| setSelectedCell( { | ||
| sectionName: name, | ||
| rowIndex, | ||
| columnIndex, | ||
| type: 'cell', | ||
| } ); | ||
| } } | ||
| aria-label={ cellAriaLabel[ name ] } | ||
| placeholder={ placeholder[ name ] } | ||
| /> | ||
| </CellTag> | ||
| ) | ||
| ) } | ||
| </tr> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this anymore. It renders in
<div>by default.