Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Add aria-label for table toolbar #201

Merged
merged 4 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lang/contexts.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"Merge cell left": "Label for the merge table cell left button.",
"Split cell vertically": "Label for the split table cell vertically button.",
"Split cell horizontally": "Label for the split table cell horizontally button.",
"Merge cells": "Label for the merge table cells button."
"Merge cells": "Label for the merge table cells button.",
"Table toolbar": "The label used by assistive technologies describing a table toolbar attached to a table widget."
}
3 changes: 3 additions & 0 deletions src/tabletoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class TableToolbar extends Plugin {
*/
afterInit() {
const editor = this.editor;
const t = editor.t;
const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );

const tableContentToolbarItems = editor.config.get( 'table.contentToolbar' );
Expand All @@ -50,13 +51,15 @@ export default class TableToolbar extends Plugin {

if ( tableContentToolbarItems ) {
widgetToolbarRepository.register( 'tableContent', {
ariaLabel: t( 'Table toolbar' ),
items: tableContentToolbarItems,
getRelatedElement: getTableWidgetAncestor
} );
}

if ( tableToolbarItems ) {
widgetToolbarRepository.register( 'table', {
ariaLabel: t( 'Table toolbar' ),
items: tableToolbarItems,
getRelatedElement: getSelectedTableWidget
} );
Expand Down
8 changes: 8 additions & 0 deletions tests/tabletoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ describe( 'TableToolbar', () => {
balloonClassName: 'ck-toolbar-container'
} );
} );

it( 'should set aria-label attribute', () => {
toolbar.render();

expect( toolbar.element.getAttribute( 'aria-label' ) ).to.equal( 'Table toolbar' );

toolbar.destroy();
} );
} );

describe( 'integration with the editor focus', () => {
Expand Down