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

Font options are not toggleable any longer #615

Merged
merged 17 commits into from
Jul 31, 2017
Merged

Font options are not toggleable any longer #615

merged 17 commits into from
Jul 31, 2017

Conversation

msamsel
Copy link
Contributor

@msamsel msamsel commented Jul 6, 2017

What is the purpose of this pull request?

New feature

Does your PR contain necessary tests?

yes

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

  • Disable possibility to toggle option on drop down list of: font size, font family name, paragraph format
  • Add (Default) option to font size and font family name, which remove formating from selection
  • Add new language entry with Default to lang.common file
  • Fix one unit test which click twice into this same menu option and start to fail after change

close #584

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Looks good, some minor changes needed.

Have you used langtool to generate language files? I don't see any new entry in meta language files.

this.startGroup( lang.panelTitle );

for ( var i = 0; i < names.length; i++ ) {
var name = names[ i ];
// Add `(Default)` item as first element on the drop down list.
Copy link
Contributor

Choose a reason for hiding this comment

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

// Add (Default) item as a first element on the drop down list.

endBoundary,
node,
bm,
defaultValue = 'cke-default';
Copy link
Contributor

Choose a reason for hiding this comment

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

Same default value is already defined in an init method, maybe it could be extracted somewhere to be more "global"? Especially that it is used also in other places (tests).


editor[ style.checkActive( elementPath, editor ) ? 'removeStyle' : 'applyStyle' ]( style );
// Always aply style, do not allow on toggle it by clicking on list item (#584).
Copy link
Contributor

Choose a reason for hiding this comment

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

// Always apply style, do not allow on toggle it by clicking on list item (#584).


editor[ style.checkActive( elementPath, editor ) ? 'removeStyle' : 'applyStyle' ]( style );
// Always aply style, do not allow on toggle it by clicking on list item (#584).
editor.applyStyle( style );
Copy link
Contributor

Choose a reason for hiding this comment

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

By default all format tags are block elements so reapplying them to partial selection doesn't do anything. However, if you change the config like:

config.format_p = { element: 'span', attributes: { 'class': 'normalPara' } };

You can apply it to partial selection despite the fact it was already applied (so it creates nested tags). This is an edge case IMHO but still we should handle this. You could just check if style is active (as before style.checkActive( elementPath, editor )) and apply it only if it is not already there.

@@ -170,6 +172,43 @@
'<p>x<span style="font-size:12px"><em>foo</em></span><em><span style="font-size:24px">bar</span></em>x@</p>' );
},

// #584
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any test checking if second click (reapplying) of the same font/size doesn't change the content?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see there is on in a format plugin. Still those are separate plugin with different code so it should be tested for both.

@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, font, elementspath, sourcearea

1. Select text
Copy link
Contributor

Choose a reason for hiding this comment

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

Each list item should end with .. Select some text sounds a little better.

@msamsel
Copy link
Contributor Author

msamsel commented Jul 13, 2017

I hope it is fixed now :)

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

One failing test on IE8:
image

Same test throws timeout on IE9-11.

@@ -81,3 +81,4 @@ common.keyboard.36 = Label for the "Home" key.
common.keyboard.46 = Label for the "Delete" key.
common.keyboard.224 = Label for the "Command" key.
common.keyboardShortcut = ARIA message for keyboard shortcuts.
common.optionDefault = "(Default)" option for drop-down menues of text styling, which removes specific style.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe something like:

Label for "(Default)" option in drop-down text-styling menus. Using such option restores default styling.

this.startGroup( lang.panelTitle );

for ( var i = 0; i < names.length; i++ ) {
var name = names[ i ];
// Add `(Default)` item as a first element on the drop down list.
Copy link
Contributor

Choose a reason for hiding this comment

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

Use consistent naming: drop-down.

this.assertCombo( 'Font', 'cke-default', false, bot, '<p>foo@</p>' );
},

'test reaaply this same font size twice': function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

reapply


},

'test reaaply this same font family twice': function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

reapply

@bender-ckeditor-plugins: wysiwygarea, toolbar, font, elementspath, sourcearea

1. Select some text.
1. Change `font size`, (e.g. `24`).
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundant comma after size:

  1. Change font size, (e.g. 24).

@bender-ckeditor-plugins: wysiwygarea, toolbar, format, elementspath, sourcearea

1. Select text
1. Try to apply multiple times this same format to one selection (different than normal).
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to apply same format (other than Normal) multiple times.

?

1. Select text
1. Try to apply multiple times this same format to one selection (different than normal).

**Expected:** Choosen format should remain this same all the time.
Copy link
Contributor

Choose a reason for hiding this comment

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

should remain thisthe same all the time.


**Expected:** Choosen format should remain this same all the time.

**Unexpected:** Text format toggle between styled and unstyled (Normal) one.
Copy link
Contributor

Choose a reason for hiding this comment

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

toggles

@@ -25,5 +25,29 @@ bender.test( {
bot.setHtmlWithSelection( '<fieldset><legend>^foo</legend><form>bar</form></fieldset>' );
var name = 'Format', combo = ed.ui.get( name );
assert.areSame( CKEDITOR.TRISTATE_DISABLED, combo._.state, 'check state disabled when not in context' );
},

// Drop down format menu should not have possibility to toggle option (#584).
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop-down

combo = editor.ui.get( name );

bot.setHtmlWithSelection( '<p>^foo</p>' );
// apply format 1st time
Copy link
Contributor

Choose a reason for hiding this comment

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

Use full sentences, e.g. Apply format 1st time.

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Earlier mentioned tests (despite the fact it was adjusted) seems to still be unstable on IE8. When run in group it seems to fail in most cases. When only test suite is run it fails like 50% of times. When the test itself is run it sometimes fails. Seems like some issue with focus, if I click inside a browser window before running in most cases it works.

I see this test was based on an existing one, but the former one seems to work fine. Maybe it affects the second test somehow?

@@ -67,7 +67,10 @@ CKEDITOR.plugins.add( 'format', {
var style = styles[ value ],
elementPath = editor.elementPath();

editor[ style.checkActive( elementPath, editor ) ? 'removeStyle' : 'applyStyle' ]( style );
// Always apply style, do not allow on toggle it by clicking on list item (#584).
Copy link
Contributor

Choose a reason for hiding this comment

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

Always apply style, do not allow to toggle it by clicking on corresponding list item (#584).

?

@@ -35,8 +48,10 @@

this.wait( function() {
// Click again to exit the style.
// Since 4.8.0 2nd click into this same menu item do not unselect it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since 4.8.0, 2nd click on the same menu item does not unselect it.

@@ -35,8 +48,10 @@

this.wait( function() {
// Click again to exit the style.
// Since 4.8.0 2nd click into this same menu item do not unselect it.
// It is required to click into '(Default)' option to reset style (#584).
Copy link
Contributor

Choose a reason for hiding this comment

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

It is required to click on the '(Default)' option to reset style (#584).

bot.combo( name, function( combo ) {
assert.areSame( CKEDITOR.TRISTATE_ON, combo.getState(), 'check state ON when opened' );
combo.onClick( 'h1' );
assert.areSame( '<h1>f^oo</h1>', bot.htmlWithSelection(), 'applied h1 block style' );
Copy link
Contributor

Choose a reason for hiding this comment

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

applied h1 block style

h1 was not applied here as it was already there. The test (and assert) check if h1 is not removed when applied second time, so maybe preserved h1 block style or something similar?

@msamsel
Copy link
Contributor Author

msamsel commented Jul 28, 2017

It seems that sometimes IE8 on some system can have strange behaviour. I removed checking if the format panel is opened and left only checking styles if it's properly applied.

@f1ames f1ames self-requested a review July 28, 2017 12:53
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

LGTM!

@f1ames f1ames merged commit ef464ec into major Jul 31, 2017
@f1ames f1ames deleted the t/584 branch July 31, 2017 07:49
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.

Fonts setting should not be toggling options
2 participants