Opened 11 years ago
Closed 9 years ago
#11616 closed Bug (fixed)
(Chrome) Resizing the editor while it's not displayed
Reported by: | sigurdhj | Owned by: | Szymon Cofalik |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.5.2 |
Component: | General | Version: | 3.6.3 |
Keywords: | Blink Webkit Support | Cc: |
Description
Issue
If the editor gets resized while not shown, I can't interact with the textarea when I decide to display the editor again.
Steps to reproduce
- Open JSFiddle http://jsfiddle.net/jtf3f/7/ in Chrome
- Resize the browser
- Click 'Toggle editor'-button
- Try to write anything in the editor
Browser & OS
- Browser: Google Chrome Version 33.0.1750.117 m
- OS: Windows 7 (x64) Enterprise SP 1
The issue is for Chrome only, I'm not experiencing the issue with Firefox and IE.
Attachments (2)
Change History (17)
comment:1 Changed 11 years ago by
Keywords: | Blink Webkit added |
---|---|
Status: | new → confirmed |
Version: | 4.3.3 → 3.6.3 |
Changed 11 years ago by
Attachment: | 11616.html added |
---|
comment:2 Changed 10 years ago by
#12913 was marked as duplicate.
Comment from that ticket (a little bit modified):
- Place attached test.html file in samples folder
- Open the html file in Google Chrome/Opera or Safari
- Note: There is text in the CKEditor and it is editable
- Click the "Hide CKEditor" button
- Resize your browser window
- Click the "Show CKEditor" button
- Note: The text is missing from the editor, the editor is not editable (the reason is the CKEditor's iframe has width = 0)
- Resize your browser window again
- Note: The text is now visible/editable on the editor again
Changed 10 years ago by
comment:4 Changed 9 years ago by
This patch addresses a bug within CKEditor in webkit-based browsers causing the editor contents to become invisible when the browser is resized with the editor hidden from view. When the editor appears again, the contents will not be shown until the editor is resized. This is caused by "contentSpace.getSize( 'width' )" returning 0 when the editor is hidden.
Patched for version 4.4.7
Uncompressed CKEditor:
File: /ckeditor/plugins/wysiwygarea/plugin.js
Unpatched code:
if ( CKEDITOR.env.webkit ) { // Webkit: iframe size doesn't auto fit well. (#7360) var onResize = function() { // Hide the iframe to get real size of the holder. (#8941) contentSpace.setStyle( 'width', '100%' ); iframe.hide(); iframe.setSize( 'width', contentSpace.getSize( 'width' ) ); contentSpace.removeStyle( 'width' ); iframe.show(); }; iframe.setCustomData( 'onResize', onResize ); CKEDITOR.document.getWindow().on( 'resize', onResize ); }
Patched code:
if ( CKEDITOR.env.webkit ) { // Webkit: iframe size doesn't auto fit well. (#7360) var onResize = function() { // Hide the iframe to get real size of the holder. (#8941) contentSpace.setStyle( 'width', '100%' ); iframe.hide(); var x = contentSpace.getSize( 'width' ); if (x) { iframe.setSize( 'width', x ); contentSpace.removeStyle( 'width' ); } iframe.show(); }; iframe.setCustomData( 'onResize', onResize ); CKEDITOR.document.getWindow().on( 'resize', onResize ); }
Compressed CKEditor:
File: /ckeditor/ckeditor.js
Unpatched code:
d.setAttribute("title",f));if(h){var f=CKEDITOR.tools.getNextId(),i=CKEDITOR.dom.element.createFromHtml('<span id="'+f+'" class="cke_voice_label">'+h+"</span>");g.append(i,1);d.setAttribute("aria-describedby",f)}a.on("beforeModeUnload",function(a){a.removeListener();i&&i.remove()});d.setAttributes({tabIndex:a.tabIndex,allowTransparency:"true"});!c&&b();CKEDITOR.env.webkit&& (c=function(){g.setStyle("width","100%");d.hide();d.setSize("width",g.getSize("width"));g.removeStyle("width");d.show()}
Patched code:
d.setAttribute("title",f));if(h){var f=CKEDITOR.tools.getNextId(),i=CKEDITOR.dom.element.createFromHtml('<span id="'+f+'" class="cke_voice_label">'+h+"</span>");g.append(i,1);d.setAttribute("aria-describedby",f)}a.on("beforeModeUnload",function(a){a.removeListener();i&&i.remove()});d.setAttributes({tabIndex:a.tabIndex,allowTransparency:"true"});!c&&b();CKEDITOR.env.webkit&& (c=function(){g.setStyle("width","100%");d.hide();var x=g.getSize("width");if (x){d.setSize("width",x);g.removeStyle("width");}d.show()}
Hope this helps anyone with the same problem.
comment:5 Changed 9 years ago by
@dtekk, could I as you to provide this fix as a pull request for CKEditor 4.x? You could provide this fix as a pull request for CKEditor 4.x? You could submit it to ckeditor-dev
If you decide to do so, please don't forget to describe exactly what or which bug this pull request fixes. Because tests are required, please also see http://docs.ckeditor.com/#!/guide/dev_contributing_code.
comment:6 Changed 9 years ago by
Keywords: | Support added |
---|
This issue has also been reported on support channel.
comment:8 Changed 9 years ago by
Owner: | set to Szymon Cofalik |
---|---|
Status: | confirmed → assigned |
comment:9 Changed 9 years ago by
Status: | assigned → review |
---|
@dtekk - thanks for your contribution.
Code submitted by @dtekk works fine. However I was a bit hesitant to use it - it is still hard to tell what would be the size of the iframe
when after showing it (It will have width:100%
but that code for webkits was written because width:100%
supposedly wasn't correct).
However the code for webkit fixes the bug that is 3 years old. I commented out the whole if:
if ( CKEDITOR.env.webkit ) { // Webkit: iframe size doesn't auto fit well. (#7360) var onResize = function() { // Hide the iframe to get real size of the holder. (#8941) contentSpace.setStyle( 'width', '100%' ); iframe.hide(); iframe.setSize( 'width', contentSpace.getSize( 'width' ) ); contentSpace.removeStyle( 'width' ); iframe.show(); }; iframe.setCustomData( 'onResize', onResize ); CKEDITOR.document.getWindow().on( 'resize', onResize ); }
And can't reproduce the original bug.
So, I think there are two ways we can go now: we either remove whole if and the bug described in this ticket will be gone, but we might have regression if someone, somehow uses old version of webkit ==> branch:t/13422
or
I can just apply @dtekk's soultion - which will work fine as well, because even if width
will be set to 100%
it still works fine on modern browsers ==> branch:t/13422b
Both branches have a test for this ticket.
comment:10 Changed 9 years ago by
@j.swiderski, Reinmar & scofalik
Thanks for working so quickly on this, much appreciated!
@j.swiderski
I'll be sure to provide the fix as a pull request for future bugs. Thanks for those resources.
comment:11 Changed 9 years ago by
Status: | review → review_failed |
---|
OK, I'll go with the branch:t/11616 approach. Removing code is always better than adding more code and I'm also unable to reproduce the old bug.
What I miss is a manual TC for #7360. Let's be sure that this really isn't a problem any more. Other than that, remember to change 4.5.1 tag in the existing manual TC to 4.5.2.
comment:12 Changed 9 years ago by
comment:13 Changed 9 years ago by
Status: | review_failed → assigned |
---|
comment:14 Changed 9 years ago by
Status: | assigned → review |
---|
Since tickets you have mentioned are connected with old versions of CKE I just scouted through those tickets and tried to recreate described scenarios. I added some new test cases. branch:t/11616
comment:15 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | review → closed |
Fixed on master with git:168ea63.
I removed one of the tests that you created because it was invalid. It was trying to set data synchronously what's incorrect because initialization and setting data is asynchronous.
I'll close also #9160 and #9715 because I could not reproduce them and both mentions that code as the trigger.
I was able to reproduce this problem from CKEditor 3.6.3 rev. [7387] in Blink and Webkit browsers.