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

Commit

Permalink
Merge pull request #201 from ckeditor/t/ckeditor5/1404
Browse files Browse the repository at this point in the history
Other: The table widget toolbar should have a proper `aria-label` attribute (see ckeditor/ckeditor5#1404).
  • Loading branch information
oleq authored Aug 13, 2019
2 parents 8cc3436 + d7f9d0f commit b47a94f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
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

0 comments on commit b47a94f

Please sign in to comment.