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

Fixed: fake selection allows for removing in a readonly mode #1525

Merged
merged 6 commits into from
Feb 6, 2018
Merged

Conversation

jacekbogdanski
Copy link
Member

What is the purpose of this pull request?

Bug fix.

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?

Disabled deleting selection in a readonly mode for fake selection.

Closes #1516


editor.setReadOnly( true );

bot.setData( '<p>[[placeholder]]</p>', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please restore editor readOnly state back to false as any subsequent TCs would be fired on readonly instance (which is unexpected).

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.

It seems that the only existing issue is the one already mentioned by @mlewand.

} );

// Teardown
editor.setReadOnly( false );
Copy link
Member

Choose a reason for hiding this comment

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

If test fails, the editor will remain read only. I'd rather move it to tearDown function.

What's more, due to the fact that bot.setData is async and how YUITest works, this line won't be ever executed (async in YUITest is based on throwing exceptions and handling them).

@@ -785,5 +786,25 @@ bender.test( {
bender.tools.setHtmlWithSelection( editor, '<p>T^es^t</p>' );

assert.isFalse( editor.getSelection().isCollapsed() );
},

'test delete/backspace keys are not removing readonly selection': function() {
Copy link
Member

Choose a reason for hiding this comment

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

Actually this test should be moved to fake.js file (as it's connected with fake – not real – selection).

Also please add ticket reference.

Copy link
Member

Choose a reason for hiding this comment

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

Test does not work in IE8 – error is thrown instead.

CHANGES.md Outdated
@@ -24,6 +24,7 @@ Fixed Issues:
* [#1356](https://github.com/ckeditor/ckeditor-dev/issues/1356): Fixed: [Border parse function](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.tools.style.parse-method-border) should allow spaces in the color value.
* [#1426](https://github.com/ckeditor/ckeditor-dev/issues/1426): [IE8-9] Fixed: Missing balloon toolbar background in Kama skin. Thanks to [Christian Elmer](https://github.com/keinkurt)!
* [#1010](https://github.com/ckeditor/ckeditor-dev/issues/1010): Fixed: CSS `border` shorthand property was incorrectly expanded ignoring `border-color` style.
* [#1516](https://github.com/ckeditor/ckeditor-dev/issues/1516): Fixed: Selection allows for removing in a readonly mode using `backspace/delete` keys.
Copy link
Member

Choose a reason for hiding this comment

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

Please add info that it's a fake selection.

@@ -526,6 +526,10 @@
range = editor.createRange(),
found;

if ( editor.readOnly ) {
Copy link
Member

Choose a reason for hiding this comment

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

Please add reference to the issue.

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.

One, super small tweak and it's ready!

@@ -0,0 +1,16 @@
@bender-tags: selection, fake, widget, 4.9.0, bug, 1516
Copy link
Member

Choose a reason for hiding this comment

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

Please ignore also this test as it also does not work at all in IE.

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! 👍

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.

Fake selection allows for removing in a readonly mode
3 participants