-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
There was a problem hiding this 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"> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
.
There was a problem hiding this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Image reference.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
917169d
to
028f922
Compare
There was a problem hiding this 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' ) ); |
There was a problem hiding this comment.
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.
8ae1821
to
f0f3a3d
Compare
There was a problem hiding this 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.
tests/core/selection/fake.js
Outdated
}; | ||
|
||
for ( item in expected ) { | ||
assert.areEqual( expected[ item ], styles[ item ] ); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test file typo.
tests/core/selection/fake.js
Outdated
|
||
altContainer = editor.editable().findOne( '[data-cke-hidden-sel]' ); | ||
|
||
// On IE and Edge < 14 element should have `display:none`. |
There was a problem hiding this comment.
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.
b65feb6
to
f0adfb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
e191db8
to
cdd7c9f
Compare
There was a problem hiding this 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. |
There was a problem hiding this comment.
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".
tests/core/selection/fake.js
Outdated
}, | ||
|
||
// (#898) | ||
'Test image long alt visibility': function() { |
There was a problem hiding this comment.
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.
tests/core/selection/fake.js
Outdated
|
||
editor.getSelection().fake( editor.document.getById( 'bar' ), '<i>foo</i>' ); | ||
|
||
altContainer = editor.editable().findOne( '[data-cke-hidden-sel]' ); |
There was a problem hiding this comment.
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.
tests/core/selection/fake.js
Outdated
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 14 ) { | ||
assert.areEqual( 'none', altContainer.getStyle( 'display' ) ); | ||
} else { | ||
styles = CKEDITOR.tools.parseCssText( altContainer.getAttributes().style ); |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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
What changes did you make?
I've added following styling to hiddenSelection:
width:0;height:0
Closes #898