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 #246 from ckeditor/t/ckeditor5/1403
Browse files Browse the repository at this point in the history
Fix: The UI buttons should be marked as toggleable for better assistive technologies support (see ckeditor/ckeditor5#1403).
  • Loading branch information
oleq authored Aug 12, 2019
2 parents a909db4 + a19957b commit b9e31a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/linkui.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ export default class LinkUI extends Plugin {
button.icon = linkIcon;
button.keystroke = linkKeystroke;
button.tooltip = true;
button.isToggleable = true;

// Bind button to the command.
button.bind( 'isOn', 'isEnabled' ).to( linkCommand, 'value', 'isEnabled' );
button.bind( 'isEnabled' ).to( linkCommand, 'isEnabled' );
button.bind( 'isOn' ).to( linkCommand, 'value', value => !!value );

// Show the panel on button click.
this.listenTo( button, 'execute', () => this._showUI( true ) );
Expand Down
8 changes: 6 additions & 2 deletions tests/linkui.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,21 @@ describe( 'LinkUI', () => {
expect( linkButton ).to.be.instanceOf( ButtonView );
} );

it( 'should be toggleable button', () => {
expect( linkButton.isToggleable ).to.be.true;
} );

it( 'should be bound to the link command', () => {
const command = editor.commands.get( 'link' );

command.isEnabled = true;
command.value = true;
command.value = 'http://ckeditor.com';

expect( linkButton.isOn ).to.be.true;
expect( linkButton.isEnabled ).to.be.true;

command.isEnabled = false;
command.value = false;
command.value = undefined;

expect( linkButton.isOn ).to.be.false;
expect( linkButton.isEnabled ).to.be.false;
Expand Down

0 comments on commit b9e31a0

Please sign in to comment.