Browse Source

Merge pull request #246 from ckeditor/t/ckeditor5/1403

Fix: The UI buttons should be marked as toggleable for better assistive technologies support (see ckeditor/ckeditor5#1403).
Aleksander Nowodzinski 6 years ago
parent
commit
67e19c517d
2 changed files with 9 additions and 3 deletions
  1. 3 1
      packages/ckeditor5-link/src/linkui.js
  2. 6 2
      packages/ckeditor5-link/tests/linkui.js

+ 3 - 1
packages/ckeditor5-link/src/linkui.js

@@ -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 ) );

+ 6 - 2
packages/ckeditor5-link/tests/linkui.js

@@ -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;