-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessibility for Font size/family and Heading dropdowns in toolbar #13893
Changes from 16 commits
a3c2c06
bc885ed
d080e30
e2a5883
31592e1
6d440a5
ba22bd6
18aab09
5112433
f049734
d3bc60a
664dd78
cc6a385
b65e8cb
4680819
9a14ac0
5099dac
8cb8508
592aedf
5a17cbb
2890137
ebacd08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,26 @@ export default class ButtonView extends View<HTMLButtonElement> implements Butto | |
*/ | ||
declare public withKeystroke: boolean; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public role: string | undefined; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public ariaChecked: boolean | undefined; | ||
Comment on lines
+146
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we need these in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we do. Added. |
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public ariaLabel?: string | undefined; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public ariaLabelledBy: string | undefined; | ||
|
||
/** | ||
* Tooltip of the button bound to the template. | ||
* | ||
|
@@ -160,6 +180,9 @@ export default class ButtonView extends View<HTMLButtonElement> implements Butto | |
const ariaLabelUid = uid(); | ||
|
||
// Implement the Button interface. | ||
this.set( 'ariaChecked', undefined ); | ||
this.set( 'ariaLabel', undefined ); | ||
this.set( 'ariaLabelledBy', `ck-editor__aria-label_${ ariaLabelUid }` ); | ||
this.set( 'class', undefined ); | ||
this.set( 'labelStyle', undefined ); | ||
this.set( 'icon', undefined ); | ||
|
@@ -169,6 +192,7 @@ export default class ButtonView extends View<HTMLButtonElement> implements Butto | |
this.set( 'isToggleable', false ); | ||
this.set( 'keystroke', undefined ); | ||
this.set( 'label', undefined ); | ||
this.set( 'role', undefined ); | ||
this.set( 'tabindex', -1 ); | ||
this.set( 'tooltip', false ); | ||
this.set( 'tooltipPosition', 's' ); | ||
|
@@ -177,7 +201,7 @@ export default class ButtonView extends View<HTMLButtonElement> implements Butto | |
this.set( 'withKeystroke', false ); | ||
|
||
this.children = this.createCollection(); | ||
this.labelView = this._createLabelView( ariaLabelUid ); | ||
this.labelView = this._createLabelView(); | ||
|
||
this.iconView = new IconView(); | ||
this.iconView.extendTemplate( { | ||
|
@@ -209,10 +233,13 @@ export default class ButtonView extends View<HTMLButtonElement> implements Butto | |
bind.if( 'withText', 'ck-button_with-text' ), | ||
bind.if( 'withKeystroke', 'ck-button_with-keystroke' ) | ||
], | ||
role: bind.to( 'role' ), | ||
type: bind.to( 'type', value => value ? value : 'button' ), | ||
tabindex: bind.to( 'tabindex' ), | ||
'aria-labelledby': `ck-editor__aria-label_${ ariaLabelUid }`, | ||
'aria-label': bind.to( 'ariaLabel' ), | ||
'aria-labelledby': bind.to( 'ariaLabelledBy' ), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing test checks if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test added. |
||
'aria-disabled': bind.if( 'isEnabled', true, value => !value ), | ||
'aria-checked': bind.to( 'isOn' ), | ||
'aria-pressed': bind.to( 'isOn', value => this.isToggleable ? String( !!value ) : false ), | ||
'data-cke-tooltip-text': bind.to( '_tooltipString' ), | ||
'data-cke-tooltip-position': bind.to( 'tooltipPosition' ) | ||
|
@@ -274,10 +301,8 @@ export default class ButtonView extends View<HTMLButtonElement> implements Butto | |
|
||
/** | ||
* Creates a label view instance and binds it with button attributes. | ||
* | ||
* @param ariaLabelUid The aria label UID. | ||
*/ | ||
private _createLabelView( ariaLabelUid: string ) { | ||
private _createLabelView() { | ||
const labelView = new View(); | ||
const bind = this.bindTemplate; | ||
|
||
|
@@ -290,7 +315,7 @@ export default class ButtonView extends View<HTMLButtonElement> implements Butto | |
'ck-button__label' | ||
], | ||
style: bind.to( 'labelStyle' ), | ||
id: `ck-editor__aria-label_${ ariaLabelUid }` | ||
id: this.ariaLabelledBy | ||
}, | ||
|
||
children: [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,16 @@ export default class SplitButtonView extends View<HTMLDivElement> implements Dro | |
*/ | ||
declare public labelStyle: string | undefined; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public ariaLabel?: string | undefined; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
declare public ariaLabelledBy: string | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need these? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No we don't. Last time I checked this I was getting errors regarding not implementing the interface correctly for SplitButtonView. But now it seems to work without these declarations. |
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,6 +310,7 @@ export function addListToDropdown( | |
itemsOrCallback: Collection<ListDropdownItemDefinition> | ( () => Collection<ListDropdownItemDefinition> ), | ||
options: { | ||
ariaLabel?: string; | ||
role?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing API docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||
} = {} | ||
): void { | ||
if ( dropdownView.isOpen ) { | ||
|
@@ -340,6 +341,7 @@ function addListToOpenDropdown( | |
itemsOrCallback: Collection<ListDropdownItemDefinition> | ( () => Collection<ListDropdownItemDefinition> ), | ||
options: { | ||
ariaLabel?: string; | ||
role?: string; | ||
} | ||
): void { | ||
const locale = dropdownView.locale; | ||
|
@@ -348,6 +350,7 @@ function addListToOpenDropdown( | |
const items = typeof itemsOrCallback == 'function' ? itemsOrCallback() : itemsOrCallback; | ||
|
||
listView.ariaLabel = options.ariaLabel; | ||
listView.role = options.role; | ||
|
||
listView.items.bindTo( items ).using( def => { | ||
if ( def.type === 'separator' ) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes have no test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Added.