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

Long image alt text protrudes into editor when image is selected #1435

Merged
merged 25 commits into from
Sep 27, 2018

Conversation

engineering-this
Copy link
Contributor

@engineering-this engineering-this commented Jan 10, 2018

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?

I've added following styling to hiddenSelection: width:0;height:0

Closes #898

@mlewand mlewand added the review:easy Pull requests that can be reviewed by a Junior Developer before being reviewed by the Reviewer. label Jul 18, 2018
@jacekbogdanski jacekbogdanski self-requested a review July 18, 2018 10:00
@jacekbogdanski jacekbogdanski self-assigned this Jul 18, 2018
Copy link
Member

@jacekbogdanski jacekbogdanski left a comment

Choose a reason for hiding this comment

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

The fix seems to work. However, this PR needs some polishing. Please rebase it into the latest upstream.

There is also a missing unit test.

@@ -0,0 +1,7 @@
<div id="editor" contenteditable="true">
Copy link
Member

Choose a reason for hiding this comment

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

There is no need for conteneditable attribute.

@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, image2

## Image with long alt
Copy link
Member

Choose a reason for hiding this comment

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

Please, refactor this file into our adopted test file structure.

CHANGES.md Outdated
@@ -16,6 +16,7 @@ Fixed Issues:
* [#889](/~https://github.com/ckeditor/ckeditor-dev/issues/889): Fixed: Unclear error message for width and height fields in [Image](https://ckeditor.com/cke4/addon/image) and [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugins.
* [#859](/~https://github.com/ckeditor/ckeditor-dev/issues/859): Fixed: Can't edit link after double click on text in link.
* [#1013](/~https://github.com/ckeditor/ckeditor-dev/issues/1013): Fixed: [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) does not work correctly with [`config.forcePasteAsPlainText`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-forcePasteAsPlainText) property.
* [#898](/~https://github.com/ckeditor/ckeditor-dev/issues/898): Fixed: Long image alt text protrudes into editor when image is selected.
Copy link
Member

Choose a reason for hiding this comment

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

Update changelog to target upstream minor.

Copy link
Member

@jacekbogdanski jacekbogdanski left a comment

Choose a reason for hiding this comment

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

Originally the issue exists inside a fake selection code, not image2. I think that it would be nice to move tests into correct namespace i.e core/selection/fake and refactor test case names thus it's not about invalid alt hiding, but fake selection container.

CHANGES.md Outdated
@@ -11,6 +11,7 @@ Fixed Issues:
* [#2167](/~https://github.com/ckeditor/ckeditor-dev/issues/2167): Fixed: Matching in [Emoji](https://ckeditor.com/cke4/addon/emoji) plugin is not case insensitive.
* [#1084](/~https://github.com/ckeditor/ckeditor-dev/issues/1084) Fixed: Using the "Automatic" option with [Color Button](https://ckeditor.com/cke4/addon/colorbutton) on a text with color already defined sets an invalid color value.
* [#966](/~https://github.com/ckeditor/ckeditor-dev/issues/966): Fixed: Executing [`editor.destroy()`](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_editor.html#destroy) during [file upload](https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_fileTools_uploadWidgetDefinition.html#onUploading) throws error. Thanks to [Maksim Makarevich](/~https://github.com/MaksimMakarevich)!
* [#898](/~https://github.com/ckeditor/ckeditor-dev/issues/898): Fixed: Long image alt text protrudes into editor when image is selected.
Copy link
Member

Choose a reason for hiding this comment

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

Add Image reference.

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 agree about moving it to proper namespace, but also I want to clarify, that it is unrelated to fake selection. It is related to hidden selection, which refers to hidden elements which will be copied to clipboard on users copy action. In our case it is an alt text.

Copy link
Member

Choose a reason for hiding this comment

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

Please, see where hideSelection function is used. In a unit testing level, it's used inside fake selection and should be tested in this namespace.

Copy link
Member

@jacekbogdanski jacekbogdanski left a comment

Choose a reason for hiding this comment

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

Is there any reason for separate unit test file? I like the idea to keep clean namespaces, although it's single test case and we already have hidden container unit tests inside tests/core/selection/fake.js.

} else {
// Other browers should have 0 with and 0 height.
assert.areEqual( '0px', altContainer.getStyle( 'height' ) );
assert.areEqual( '0px', altContainer.getStyle( 'width' ) );
Copy link
Member

Choose a reason for hiding this comment

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

I know that you just added width and height styles but it would be nice to test full style position:fixed;top:0;left:-1000px;width:0;height:0 in such test.

@engineering-this engineering-this force-pushed the t/898 branch 2 times, most recently from 8ae1821 to f0f3a3d Compare August 31, 2018 15:34
@engineering-this engineering-this self-assigned this Aug 31, 2018
@engineering-this engineering-this changed the base branch from master to next August 31, 2018 15:39
@jacekbogdanski jacekbogdanski self-assigned this Sep 3, 2018
Copy link
Member

@jacekbogdanski jacekbogdanski left a comment

Choose a reason for hiding this comment

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

Looks fine, some minor issues which I will fix in the upcoming commits.

};

for ( item in expected ) {
assert.areEqual( expected[ item ], styles[ item ] );
Copy link
Member

Choose a reason for hiding this comment

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

It may be simplified using CKEDITOR.tools.objectCompare.

@@ -0,0 +1,11 @@
@bender-tags: 4.10.2, bug, 898
Copy link
Member

Choose a reason for hiding this comment

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

Test file typo.


altContainer = editor.editable().findOne( '[data-cke-hidden-sel]' );

// On IE and Edge < 14 element should have `display:none`.
Copy link
Member

Choose a reason for hiding this comment

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

Not essentially true, this code path is for IE only. In fact, this comment is useless thus it explain code, not business reasons.

Copy link
Member

@jacekbogdanski jacekbogdanski left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Additionally manual test could have better name (e.g. hiddenselvisibility).

CHANGES.md Outdated
@@ -18,6 +18,7 @@ Fixed Issues:
API Changes:

* [#1451](/~https://github.com/ckeditor/ckeditor-dev/issues/1451): Fixed: Context menu is incorrectly positioned when opened with `Shift-F10`.
* [#898](/~https://github.com/ckeditor/ckeditor-dev/issues/898): Fixed: [Image2](https://ckeditor.com/cke4/addon/image2) long alt text protrudes into editor when image is selected.
Copy link
Member

Choose a reason for hiding this comment

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

It's not API change, entry should be in "Fixed Issues" section.

Additionally the name of the plugin is "Enhanced Image", not "Image2".

},

// (#898)
'Test image long alt visibility': 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 test does not check alt visibility, but styles for hidden selection container.


editor.getSelection().fake( editor.document.getById( 'bar' ), '<i>foo</i>' );

altContainer = editor.editable().findOne( '[data-cke-hidden-sel]' );
Copy link
Member

Choose a reason for hiding this comment

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

altContainer variable name is misleading, as there isn't any [alt] in it during the test.

if ( CKEDITOR.env.ie && CKEDITOR.env.version < 14 ) {
assert.areEqual( 'none', altContainer.getStyle( 'display' ) );
} else {
styles = CKEDITOR.tools.parseCssText( altContainer.getAttributes().style );
Copy link
Member

Choose a reason for hiding this comment

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

It's safer to check computed styles of the container, not the ones in [style] attribute as they're still possible to overwrite.


There is a visible text around the image.

# Test steps for browsers supporting JAWS text reader:
Copy link
Member

Choose a reason for hiding this comment

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

We only support Firefox + JAWS combo.

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 9bd2abc into master Sep 27, 2018
@CKEditorBot CKEditorBot deleted the t/898 branch September 27, 2018 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:easy Pull requests that can be reviewed by a Junior Developer before being reviewed by the Reviewer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants