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

Bug fix for throwing error in console where style combo was open #659

Merged
merged 4 commits into from
Jul 21, 2017

Conversation

msamsel
Copy link
Contributor

@msamsel msamsel commented Jul 19, 2017

What is the purpose of this pull request?

bug fix

Does your PR contain necessary tests?

yes

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

  • In case when style combo is opened and there is no selection in editor, now editable element will be returned as default one.

close #646

</textare>

<script>
if ( bender.tools.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.

Why this test is ignored on mobile devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error was thrown only in console. Generally during tests it's hard to analyse what happen on mobile console. So even if bug potentially might still exist, it won't be visible in such environment. That's why manual tests are ignored on mobile for this fix.

1. Press empty button in toolbar,next to style selection.
1. Press style drop down menu to open style list.

**Expected:** There is nothing happen.
Copy link
Member

Choose a reason for hiding this comment

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

Slightly ungrammatically.

var editor = bot.editor;
var selection = editor.getSelection();

var stub = sinon.stub( CKEDITOR.dom.selection.prototype, 'getNative', function() {
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this stub?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add short comment in code before stub to have this info in case of future cases.
Generally, when combo was opened, there was execute operation which operate on selection. During this process selection was reset. So in my test I wasn't able to simulate None selection and always receive Caret selection. This behaviour affect on test and doesn't allow on proper error reproduction.
To be precise I wasn't able to get elementPath = null from here: https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/stylescombo/plugin.js#L145
because of way how this work in those places:
https://github.com/ckeditor/ckeditor-dev/blob/master/core/editor.js#L860-L870
here is this.getSelection() which generally get selection based on native one here:
https://github.com/ckeditor/ckeditor-dev/blob/master/core/selection.js#L1342
And that's why I stub getNative() to reset native selection and always get None type.

@msamsel
Copy link
Contributor Author

msamsel commented Jul 21, 2017

I add some comments also under your review comments. Might be helpful ;)

@Comandeer Comandeer merged commit 05dbb0b into master Jul 21, 2017
@Comandeer Comandeer deleted the t/646 branch July 21, 2017 15:44
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.

4 participants