Skip to content

Commit

Permalink
Merge pull request #12047 from ckeditor/ck/11115-incorrect-aria-press…
Browse files Browse the repository at this point in the history
…ed-in-switch

Fix (ui): The default value of the `aria-pressed` DOM attribute of a [toggleable](https://ckeditor.com/docs/ckeditor5/latest/api/module_ui_button_button-Button.html#member-isToggleable) button should be `false` instead of `undefined`. Closes #11115.
  • Loading branch information
oleq authored Jul 15, 2022
2 parents 9f36712 + 75d5bac commit 31cf026
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ckeditor5-ui/src/button/buttonview.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default class ButtonView extends View {
tabindex: bind.to( 'tabindex' ),
'aria-labelledby': `ck-editor__aria-label_${ ariaLabelUid }`,
'aria-disabled': bind.if( 'isEnabled', true, value => !value ),
'aria-pressed': bind.to( 'isOn', value => this.isToggleable ? String( value ) : false )
'aria-pressed': bind.to( 'isOn', value => this.isToggleable ? String( !!value ) : false )
},

children: this.children,
Expand Down
6 changes: 6 additions & 0 deletions packages/ckeditor5-ui/tests/button/buttonview.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ describe( 'ButtonView', () => {
expect( view.element.attributes[ 'aria-disabled' ].value ).to.equal( 'true' );
} );

it( '-pressed has correct default value for toggleable button', () => {
view.isToggleable = true;
view.isOn = undefined;
expect( view.element.attributes[ 'aria-pressed' ].value ).to.equal( 'false' );
} );

it( '-pressed reacts to #isOn', () => {
view.isToggleable = true;
view.isOn = true;
Expand Down

0 comments on commit 31cf026

Please sign in to comment.