Skip to content
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

Merged
merged 13 commits into from
Jun 27, 2018

Conversation

engineering-this
Copy link
Contributor

@engineering-this engineering-this commented Jun 12, 2018

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

  • Unit tests
  • Manual tests

What changes did you make?

I've added support for custom aria-haspopup to UI Button plugin, via button.definition.hasPopup. Plugins extending button has now proper values:

Menu Button - menu
Panel Button - listbox

also Rich Combo value is now listbox.

Closes #2072

@@ -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.
Copy link
Member

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:

  1. Overload hasArrow and add new values to it.
  2. Create hasPopup, but deprecate hasArrow.

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.

@@ -74,6 +74,8 @@ CKEDITOR.plugins.add( 'menubutton', {

this.hasArrow = true;

this.hasPopup = 'menu';
Copy link
Member

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

@@ -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'
Copy link
Member

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
Copy link
Member

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.
Copy link
Member

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.

@@ -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() {
Copy link
Member

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.

@@ -53,6 +56,13 @@ bender.test( {
assert.areEqual( 'aria label', label.getText(), 'innerText of label doesn\'t match' );
},

'test aria-haspopup': function() {
Copy link
Member

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.

@@ -0,0 +1,18 @@
@bender-tags: 4.10.0, feature, 2072
Copy link
Member

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 ) {
Copy link
Member

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', {
Copy link
Member

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.

@@ -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
Copy link
Member

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).

@@ -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
Copy link
Member

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).

@@ -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.
Copy link
Member

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.

@@ -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,
Copy link
Member

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.

@Comandeer
Copy link
Member

I changed base branch to next as major is locked now.

@Comandeer Comandeer changed the base branch from major to next June 27, 2018 15:52
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Comandeer Comandeer merged commit c5c5e39 into next Jun 27, 2018
@Comandeer Comandeer deleted the t/2072 branch June 27, 2018 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants