Opened 12 years ago
Last modified 10 years ago
#9814 confirmed Bug
Inline editor created in "display:none" element results in editor with disabled buttons
Reported by: | buren | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 4.0 |
Keywords: | Webkit Blink | Cc: |
Description (last modified by )
If rendered as below contenteditable will be set to false automatically (I guess by ckeditor). However if I set the div #my-id as visible with javascript and at the same time set contenteditable back to true the editor will still be in readonly mode. (Sometimes I can for some reason use copy-paste to enter text to the editor but I can't write regularly with the keyboard.)
Sent by the server: <div id="my-id" style="display:none;">
<h3 contenteditable="true">Header</h3>
</div>
After page render by the browser (it changed contenteditable to false): <div id="my-id" style="display:none;">
<h3 contenteditable="false" class="ck-editable cke_editable cke_editable_inline cke_contents_ltr cke_focus"" spellcheck="false">Header</h3>
</div>
After my custom javascript (removes display:none & sets h3 tag to contenteditable="true"): <div id="my-id" style="display:none;">
<h3 contenteditable="true" class="ck-editable cke_editable cke_editable_inline cke_contents_ltr cke_focus"" spellcheck="false">Header</h3>
</div>
Issue is caused by:
- Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=133371
- Blink bug: https://code.google.com/p/chromium/issues/detail?id=313082
Workaround:
var ck = CKEDITOR.inline(element); ck.on( 'instanceReady', function( ev ) { var editor = ev.editor; editor.setReadOnly( false ); });
Attachments (2)
Change History (38)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Keywords: | inline removed |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Changed 11 years ago by
Attachment: | display_none.html added |
---|
comment:3 Changed 11 years ago by
I don't believe this ticket was handled properly. The op did not in any way suggest that he inserted element(s) into the DOM with JavaScript. He merely attempted some scripting remedies after CKEditor did not behave as he expected.
With that said, the issue still remains as of 4.3.2... Please see my attached example - drop it in your samples folder.
In Chrome (and maybe other WebKit browsers), a hidden editor instance is automatically set to readOnly mode. This is not the case in Firefox and IE.
Thanks.
comment:4 Changed 11 years ago by
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
I agree. This ticket was incorrectly closed as a DUP of #9835. There's a difference between nonexisting element and hidden element.
comment:5 Changed 11 years ago by
Keywords: | Webkit Blink added |
---|---|
Status: | reopened → confirmed |
@cheesypoof thanks for pointing this out.
Problem can be reproduced from CKEditor 4.0 in Webkit and Blink browsers only.
In CKEditor 4.0 beta editor wasn't initialized at all.
comment:6 Changed 11 years ago by
Summary: | Inline editor with css property "display:none" → Inline editor created in "display:none" element results in editor with disabled buttons |
---|
#11789 was marked as duplicate.
Here are some links from that ticket:
comment:7 Changed 11 years ago by
The description of #11789 explains the problem much better and provides a working example. This issue has already been closed falsely, probably because the original description is not clear enough. Would it be possible to update the description with the one from the duplicate issue?
After more then a year and a half it would be nice to get the balling rolling on this.
comment:8 Changed 11 years ago by
Milestone: | → CKEditor 4.4.2 |
---|
I remember that there were some problems with initializing editor in hidden elements. Problems which could not be solved. But if I remember correctly, they were related to the classic editor (using iframe). It indeed makes sense to investigate this.
What should check if editor can be initialized in hidden element and if it's usable after the element has been shown. I mean only setting display property. Not detaching editor's DOM which is a separate topic (and in case of classic editor it won't be fixed because of browsers nature and complexity of the hack).
I'm setting milestone to 4.4.2. It does not mean that we'll fix all issues. First we need to find what is really broken.
comment:10 follow-up: 11 Changed 11 years ago by
I found this Chromium issue that might be relevant: https://code.google.com/p/chromium/issues/detail?id=313082. Chromium consider all hidden elements un-editable even if they have the attribute content-editable set to true.
I'm not familiar enough with the CKEditor code base to just dive in and check if the editor uses isContentEditable. If that is the case I think we have found the origin of this issue.
Update: after some googling if found the following line of code that confirms my suspicion: https://github.com/ckeditor/ckeditor-dev/blob/master/core/dom/node.js#L727. The isReadOnly function will return false for hidden contenteditable=true elements in chrome. I'm not sure when or where this read only check is called but it guess it's not being called when the visibility of the element changes, causing the element to be stuck in read only mode.
comment:11 follow-up: 12 Changed 11 years ago by
Replying to bramcordie:
I found this Chromium issue that might be relevant: https://code.google.com/p/chromium/issues/detail?id=313082. Chromium consider all hidden elements un-editable even if they have the attribute content-editable set to true.
I'm not familiar enough with the CKEditor code base to just dive in and check if the editor uses isContentEditable. If that is the case I think we have found the origin of this issue.
Thanks! It may be a reason or one of reasons. Editor starts in read only mode and that mode is not refreshed (because how could it be) when container's visibility is changed.
comment:12 Changed 11 years ago by
Replying to Reinmar:
Editor starts in read only mode and that mode is not refreshed (because how could it be) when container's visibility is changed.
Having to watch the visibility of each element would indeed be a hassle (is it even possible without polling?). As far as I know the only way to make the editor's control bar to appear is when you focus the content-editable element. If this is the case, the focus event could be used to refresh the isReadOnly check and render the control bar correctly based on the element's current visibility.
What I ended up doing is forcing the editor out of read-only mode when it gets focused. No the cleanest solution but it works for my use case. For anyone else interested, an example below:
var editor = CKEDITOR.inline("editorID", config); editor.on('focus', function () { editor.setReadOnly(false); });
A better solution would be to use CKEditor's build in isReadOnly function whenever an inline editor gets focused and set read only mode accordingly in the background. If you can point me in the right direction to where I can implement this, I would be happy to hack on it and send you a pull request on Github.
comment:13 Changed 11 years ago by
Assumptions given by bramcordie are correct.
Updating CKEDITOR.dom.node#isReadOnly would indeed fix this particular issue, but we're concerned about its performance cost.
We're going to investigate more UCs coming from the same source.
comment:14 Changed 11 years ago by
Owner: | set to Marek Lewandowski |
---|---|
Status: | confirmed → assigned |
comment:15 Changed 11 years ago by
Status: | assigned → review |
---|
In addition i've enhanced this code a little bit to better work with contenteditable values like empty string, or TRUE
uppercased.
Pushed to t/9814 at dev and t/9814 at tests.
comment:16 Changed 11 years ago by
As for the value normalization - CKEditor requires it to be exactly true
in dozen of places and don't think we should bloat code in order to handle all variants.
Very interesting approach with using the deoptimised version. Have you checked already if editor really works when browser says that the editable element isn't editable but editor is initialized as not in read only mode?
comment:17 Changed 11 years ago by
I've tested it in case when parent div was not visible (so case when Webkit returns false
for isContentEditable
) mainly for things like selection, focus, set/getData, ACF.
It turned out not to be diffrent from inline editor in typical case. I've found one issue with selection not being inited, but it's a subject for separate ticket: #11948.
comment:19 follow-up: 22 Changed 11 years ago by
Status: | review → review_failed |
---|
- Our problem has nothing to do with webkit or any other specific browser engine. At least in my opinion supported by the research. So this line is wrong https://github.com/cksource/ckeditor-dev/blob/52c242025902e3e308b95f442aa5903bd211ec39/core/dom/node.js#L729
- And
dt/core/dom/node.html#test isReadOnly allowDeopt
is also wrong.
- And
- We do not support
contenteditable="TRUE"
orcontenteditable
orcontenteditable="tRuE"
in general. Considering those cases innode.isReadOnly
makes no sense since there are billions of other methods/conditions which simply ignore it (https://github.com/cksource/ckeditor-dev/blob/52c242025902e3e308b95f442aa5903bd211ec39/core/dom/node.js#L739-L745).
- Most of additional assertions in
dt/core/dom/node.html#test_isReadOnly
makes no sense because- 2.
- They do not mirror preceding assertions (those without an argument in
isReadOnly
).
- In
dt/core/editor/readonly.html
you specified the following editor+ // This editor is inited in hidden div, then after its initialization, its parent + // element display should be switched to visible. + inline_hidden: { + name: 'inline_hidden', + creator: 'inline', + readOnly: false, + config: { + on: { + instanceReady: function() { + // We need to show parent block after initialization. + CKEDITOR.document.getById( 'inline_hidden_wrapper' ).setStyle( 'display', 'block' ); + } + } + }
which defined an obsoleteinstanceReady
listener. It is obsolete because automated tests in this file checkeditor.readOnly
once – when editor is ready. Whatever you do next there does not change anything.
- Missing tests for framed editor and divarea in
dt/core/editor/readonly.html
.
comment:20 Changed 11 years ago by
Owner: | changed from Marek Lewandowski to Olek Nowodziński |
---|---|
Status: | review_failed → assigned |
comment:21 Changed 11 years ago by
Status: | assigned → review |
---|
Pushed a simplified solution to branch:t/9814b (+tests).
comment:22 Changed 11 years ago by
Replying to a.nowodzinski:
- Issue is present only in webkit browsers, other determine value correctly, so there is no reason to decrease performance for other browsers.
- contenteditable attribute is case-insensitive, all UA treats that this way
-
- 2
- These initial tests might be in fact duplicated for deoptimized version, and vice-versa
- That's didn't know that, good
- Correct, should be added.
At the end solution in t/9814b is essentially the same as in t/9814 but:
- not respecting uppercased values
- uses this alternative computing for all browsers, even these which does not need it
I think we should add tests to t/9814 and proceed with it, since it's not really needed to use that for all browsers.
comment:23 Changed 11 years ago by
not respecting uppercased values
We do not respect uppercased values in dozens of other places too. Hence, we can say that we require the lowercase value.
uses this alternative computing for all browsers, even these which does not need it
We should avoid per browser code branching if the situation does not force us to do so. And AFAIR the useDeopt was overriden inside isReadOnly()
, taking the free will away from developer using that method.
comment:24 Changed 11 years ago by
uses this alternative computing for all browsers, even these which does not need it
We should avoid per browser code branching if the situation does not force us to do so. And AFAIR the useDeopt was overriden inside isReadOnly(), taking the free will away from developer using that method.
Sorry for making my last comment unclear. The two points - one about code branching and one about making decision inside isReadOnly()
are independent.
BTW. More related reason for avoiding code branching - what if FF or IE will change their behaviour to conform to Webkit/Blink's? The Webkit/Blink one makes sense, so this is not impossible. Sometimes it's impossible, but this time we can handle what may come in advance.
comment:25 Changed 11 years ago by
Comment 23 was clear imo, alright in such situation t/9814b seems to be the way to go.
comment:26 Changed 11 years ago by
Hum. That's funny: yesterday it seemed to fail on all browsers but today it's indeed just Webkit. So yes, we can restrict that fix to Webkit-based browsers.
As for the support of different cases of contenteditable
attribute – no, we don't want to do that. Right now, we don't support other cases in our codebase (~25 places) so isReadOnly
should do neither.
comment:27 follow-up: 28 Changed 11 years ago by
Hum. That's funny: yesterday it seemed to fail on all browsers but today it's indeed just Webkit. So yes, we can restrict that fix to Webkit-based browsers.
Why would we do that? Please see comment:23 and comment:24.
comment:28 Changed 11 years ago by
Replying to Reinmar:
Hum. That's funny: yesterday it seemed to fail on all browsers but today it's indeed just Webkit. So yes, we can restrict that fix to Webkit-based browsers.
Why would we do that? Please see comment:23 and comment:24.
OK. As we agreed, we don't want that code branching:
isReadOnly( 1 )
will be called once per instance, thus it's a negligible performance loss- If other vendors decide to make their browsers act like Webkit/Blink, future, yet old CKEditor installations would be exposed to this issue.
branch:t/9814b (+tests)
comment:29 Changed 11 years ago by
Status: | review → assigned |
---|
It turned out that current behaviour of Blink/Webkit is inconsistent with the spec. I thought that it's not included in any spec, but it is: https://www.w3.org/Bugs/Public/show_bug.cgi?id=25908
I'll try to convince Blink/Webkit teams to fix this behaviour. For now, I'm leaving this ticket opened. We can make decision right before closing 4.4.2.
comment:30 Changed 11 years ago by
I reported also a ticket for Webkit https://bugs.webkit.org/show_bug.cgi?id=133371 because the one for Blink was reopened https://code.google.com/p/chromium/issues/detail?id=313082
So, let's wait now for engine authors reaction. If it will look promising, we'll avoid making unnecessary changes in our code.
comment:31 Changed 11 years ago by
Description: | modified (diff) |
---|
comment:32 Changed 11 years ago by
Milestone: | CKEditor 4.4.2 → CKEditor 4.4.3 |
---|---|
Owner: | Olek Nowodziński deleted |
Status: | assigned → confirmed |
According to Webkit developers this bug is not anymore reproducible on Webkit. Blink developers need some time to fix it too, so let's wait few more weeks.
comment:33 Changed 10 years ago by
Milestone: | CKEditor 4.4.3 |
---|
Both (Webkit and Blink) bugs (see comment:30) will be fixed soon, so there's no need to change anything on our side. I'm removing milestone.
comment:34 Changed 10 years ago by
This bug is no longer reproducible on Safari 7.1. So only Chrome and Opera left.
comment:35 Changed 10 years ago by
Description: | modified (diff) |
---|
I saw this in the source code.. so I guess its somewhat a feature.... but still wondering how to get around this, to be able to edit content that is displayed in collapsable boxes..
isEditable: function (a) {