-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Added custom aria-haspopup
values to UI Button, Rich Combo, Panel Button, Menu Button has now proper values
#2079
Conversation
plugins/button/plugin.js
Outdated
@@ -432,6 +433,9 @@ | |||
* editor.ui.addButton( 'my_button', { | |||
* iconHiDpi: 'assets/icons/my_button.hidpi.png' | |||
* } ) | |||
* @param {String} definition.hasPopup The value of button elements `aria-haspopup` attribute. |
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.
I don't like the fact that now we have two variables for button that mean exactly the same. What's more hasArrow
didn't even become deprecated. I'd see two ways to go:
- Overload
hasArrow
and add new values to it. - Create
hasPopup
, but deprecatehasArrow
.
If we went with 2., it'd be nice to think about better name. hasPopup
indicates that this variable is a boolean, but in fact i's an enum.
But both ways need docs for hasArrow
parameter.
plugins/menubutton/plugin.js
Outdated
@@ -74,6 +74,8 @@ CKEDITOR.plugins.add( 'menubutton', { | |||
|
|||
this.hasArrow = true; | |||
|
|||
this.hasPopup = 'menu'; |
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.
This code nicely shows the issue I mentioned: now we have two properties that do exactly the same. If we go with new property, it should be enough to declare it alone, without hasArrow
. If we go with overloading hasArrow
, then we just need to replace the value ;)
tests/plugins/button/aria.js
Outdated
@@ -14,6 +14,9 @@ bender.editor = { | |||
label: 'disabled button', | |||
modes: {} // This button should be disabled because it does not work in any of modes. | |||
} ); | |||
editor.ui.addButton( 'haspopup_btn', { | |||
hasPopup: 'foo' |
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.
Why not use some of the real values?
@@ -0,0 +1,19 @@ | |||
@bender-tags: 4.8.0, trac16893, bug |
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.
What happened to these tags?
|
||
# Test scenario: | ||
|
||
Open web inspector, for each button in menu find it's 'a' element and search for `aria-haspopup` attribute. |
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.
This test is totally unfriendly. It'd rather create list, in which all [aria-haspopup]
attributes for the buttons will be listed.
tests/plugins/richcombo/richcombo.js
Outdated
@@ -31,5 +31,11 @@ bender.test( { | |||
assert.isTrue( btnEl.hasClass( 'cke_combo' ), 'check ui type class name' ); | |||
assert.isTrue( btnEl.hasClass( 'cke_combo__custom_combo' ), 'check named ui type class name' ); | |||
assert.isTrue( btnEl.hasClass( customCls ), 'check ui item custom class name' ); | |||
}, | |||
'test aria-haspopup': function() { |
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.
Let's add issue reference.
tests/plugins/button/aria.js
Outdated
@@ -53,6 +56,13 @@ bender.test( { | |||
assert.areEqual( 'aria label', label.getText(), 'innerText of label doesn\'t match' ); | |||
}, | |||
|
|||
'test aria-haspopup': function() { |
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.
Let's add issue reference.
c72fd4d
to
c2a9400
Compare
@@ -0,0 +1,18 @@ | |||
@bender-tags: 4.10.0, feature, 2072 |
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.
I don't think that we have any other test with -
in its name. Let's rename it to ariahaspopup
</table> | ||
|
||
<script> | ||
if ( CKEDITOR.env.mobile ) { |
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.
After changing test into such form I don't see need to ignore mobile devices – test should be working just fine on mobiles.
if ( CKEDITOR.env.mobile ) { | ||
bender.ignore(); | ||
} | ||
CKEDITOR.replace( 'editor', { |
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.
I'd force English language in the test, because my Chrome claims to be Polish.
tests/plugins/richcombo/richcombo.js
Outdated
@@ -31,5 +31,12 @@ bender.test( { | |||
assert.isTrue( btnEl.hasClass( 'cke_combo' ), 'check ui type class name' ); | |||
assert.isTrue( btnEl.hasClass( 'cke_combo__custom_combo' ), 'check named ui type class name' ); | |||
assert.isTrue( btnEl.hasClass( customCls ), 'check ui item custom class name' ); | |||
}, | |||
// WAI-ARIA 1.1 has added new values for aria-haspopup property #2072 |
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.
Please adhere to our comments standard:
// Comment (#1618).
tests/plugins/button/aria.js
Outdated
@@ -53,6 +56,14 @@ bender.test( { | |||
assert.areEqual( 'aria label', label.getText(), 'innerText of label doesn\'t match' ); | |||
}, | |||
|
|||
// WAI-ARIA 1.1 has added new values for aria-haspopup property #2072 |
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.
Please adhere to our comments standard:
// Comment (#1618).
plugins/button/plugin.js
Outdated
@@ -432,6 +432,8 @@ | |||
* editor.ui.addButton( 'my_button', { | |||
* iconHiDpi: 'assets/icons/my_button.hidpi.png' | |||
* } ) | |||
* @param {String/Boolean} definition.hasArrow If button should have an arrow, and value of buttons `aria-haspopup` attribute. |
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.
It sounds strange. Maybe more like:
If boolean, indicates if button should have a dropdown. If string, acts as a value of button's
aria-haspopup
attribute.
plugins/button/plugin.js
Outdated
@@ -298,7 +298,7 @@ | |||
title: this.title + ( shortcut ? ' (' + shortcut.display + ')' : '' ), | |||
ariaShortcut: shortcut ? editor.lang.common.keyboardShortcut + ' ' + shortcut.aria : '', | |||
titleJs: env.gecko && !env.hc ? '' : ( this.title || '' ).replace( "'", '' ), | |||
hasArrow: this.hasArrow ? 'true' : 'false', | |||
hasArrow: this.hasArrow || false, |
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.
Please note that attribute should get 'false'
(string with value "false"), not a real boolean. The same is true for true
value.
I changed base branch to |
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.
LGTM!
What is the purpose of this pull request?
New feature
Does your PR contain necessary tests?
All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
What changes did you make?
I've added support for custom
aria-haspopup
toUI Button
plugin, viabutton.definition.hasPopup
. Plugins extending button has now proper values:Menu Button
-menu
Panel Button
-listbox
also
Rich Combo
value is nowlistbox
.Closes #2072