Opened 12 years ago
Closed 11 years ago
#9761 closed Bug (fixed)
setReadOnly(false) doesn't activate backspace keystroke
Reported by: | limuhob | Owned by: | Olek Nowodziński |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.1.2 |
Component: | Core : Editable | Version: | 4.0 Beta |
Keywords: | IBM | Cc: | jeremie@…, jan_wloka@…, joel.peltonen@… |
Description (last modified by )
Hi guys,
if an editor is read only, then the backspace key is blocked by this code: keystrokeHandler.blockedKeystrokes[ 8 ] = editor.readOnly;
However if I change a readOnly mode by calling the setReadOnly(false) function later, the backspace key is still blocked.
Maybe it is a good idea to active the backspace key if setReadOnly(false) is called.
Edited:
Please see comment:12 and comment:13 for explanation of this problem.
Issue can be reproduced in all browsers from CKEditor 4.0 beta.
Attachments (3)
Change History (24)
comment:1 follow-up: 2 Changed 12 years ago by
Status: | new → pending |
---|
comment:2 Changed 12 years ago by
Replying to j.swiderski:
I have just checked readOnly sample in latest editor 4.0 and didn't get this problem - backspace is working as expected.
In which browsers were you getting this problem, what are steps to reproduce this, what is the code that is causing this and can this problem be reproduced in latest editor 4.0?
Problem is in google chrome 23 on linux. Same problem in the latest editor 4.0. Sample code is here. Sorry for jquery:
<head> <script> $(document).ready(function(){ var $editme = $("#editor1"); var editor = CKEDITOR.inline($editme.get(0)); //hide contenteditable and make editor readOnly $editme.hide(); $("#activate").bind("click", function(e){ //show contenteditable and make editor writable $editme.show(); editor.setReadOnly(false); //now backspace doesn't work }); }); </script> </head> <body> <input id="activate" type="button" value="activate editable"/> <div id="editor1" contenteditable="true"> sample </div> </body>
comment:3 Changed 12 years ago by
I can confirm this bug on Windows 7 with Chrome 23.0.1271.95m, CKEditor 4.0 "Full" Release. It does not occur on IE9 or Firefox.
Specifically, I have this issue with a (huge) dynamic web application with multiple inline CKEditor instances, one of which is created in a DOM tree which is not attached to the document. When this tree is then attached to the document, the setReadOnly(false) indeed does not change the backspace handling back to normal.
So in my code, I was able to fix this issue using the following code (_editor is my CKEDITOR.editor instance)
setReadOnly: function(readOnly) { if (this._editor.readOnly !== readOnly) { this._editor.setReadOnly(readOnly); if (!readOnly) { delete this._editor.keystrokeHandler.blockedKeystrokes["8"]; //8 is Backspace } } }
I will try to investigate this further, as it is impossible for me to give you a short testcase.
comment:4 Changed 12 years ago by
Cc: | jeremie@… added |
---|---|
Type: | New Feature → Bug |
Version: | 4.0 Beta → 4.0 |
comment:6 Changed 12 years ago by
Cc: | jan_wloka@… removed |
---|---|
Resolution: | → invalid |
Status: | pending → closed |
I have tried to reproduce this issue but with on luck.
@limuhob one thing I have noticed - beside code being incomplete is that you should rather set editor to readOnly on instanceReady event. That way it has always worked for me without problems.
var $editme = $("#editable"); $editme.attr('contenteditable', true); CKEDITOR.disableAutoInline = true; var editor = CKEDITOR.inline($editme.get(0)); //hide contenteditable and make editor readOnly editor.on('instanceReady', function(ev){ editor.setReadOnly(true); $editme.hide(); }); $("#activate").bind("click", function(e){ //show contenteditable and make editor writable $editme.show(); editor.setReadOnly(false); //now backspace doesn't work });
I'm closing this issue as invalid. If you guys are able to provide working and reduced sample file that shows this problem please do so and I will reopen this issue.
comment:7 Changed 12 years ago by
I can confirm this bug on chrome/safari. This bug is related to "auto readonly" feature on contenteditable/inline.
To reproduce simply... Create a page with jqueryUI tabs.
Place an inline editor on each page (div). Then call CKEDITOR.inline(); Now initialize tabs().
If you switch to second tab (the hidden one) the editor will be readOnly, so i have a change-tab callback...
activate: function( event, ui ) {
if ( _.aFeaturedDialogWysiwygEditors ) {
for ( var i in _.aFeaturedDialogWysiwygEditors ) {
try {
this is the result of CKEDITOR.inline _.aFeaturedDialogWysiwygEditors[i].setReadOnly( false );
if ( _.aFeaturedDialogWysiwygEditors[i].keystrokeHandler && _.aFeaturedDialogWysiwygEditors[i].keystrokeHandler.blockedKeystrokes && '8' in _.aFeaturedDialogWysiwygEditors[i].keystrokeHandler.blockedKeystrokes )
delete _.aFeaturedDialogWysiwygEditors[i].keystrokeHandler.blockedKeystrokes8?;
}
catch ( e ) { }
}
}
...
}
comment:8 Changed 12 years ago by
@dynamicplus instead of me creating files and guessing what you had in mind could you please create sample test page that show the problem (HTML page that can be put in samples folder and will show the bug (jquery can be imported from Google code) ).
That way we will be working on the same code.
You have written:
If you switch to second tab (the hidden one) the editor will be readOnly
This may have something to do with - http://dev.ckeditor.com/ticket/9835#comment:2 (This works in elements available on page)
Please provide the sample so that I could see code you are having problems with and base on it I will be able to tell more.
comment:9 Changed 12 years ago by
Cc: | jan_wloka@… added |
---|---|
Keywords: | IBM added |
comment:11 Changed 11 years ago by
This should not be closed. This is a very common error for and I just now nailed it down what caused it for me. Here is a sample of of how to reproduce it very simply.
- Download the attached sample THISTEST.html, add to 4.1 samples folder
- Open in IE9, allow it to run the script
- Click "Unleash" button ad awd w ad awd awd awd a
- Click some text
- Press Backspace; does not work
Also reproducible in http://ckeditor.com/demo
- Go to demo with IE9
- Open developer console; input the following commands individually
- editor.setReadOnly();
- editor.setData("<p>foo</p>");
- editor.setReadOnly(false);
comment:12 Changed 11 years ago by
Sorry to spam you all, but I found a workaround. In my example, the following fails:
function derp() { editor.setData("<p>Lorem ipsum dolor sit amet</p>", function() { editor.setReadOnly(false); }); }
But the following works:
function derp() { editor.setReadOnly(false); editor.setData("<p>Lorem ipsum dolor sit amet</p>", function() { editor.setReadOnly(false); }); }
Meaning that the bug is very closely related to setData and not just setReadOnly. For now, it is safe to setReadOnly before setting readOnly to false, if possible for you.
comment:13 Changed 11 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
comment:14 Changed 11 years ago by
Description: | modified (diff) |
---|---|
Status: | reopened → confirmed |
Version: | 4.0 → 4.0 Beta |
comment:15 Changed 11 years ago by
I can confirm in FF 20.0.1 and IE 9.0.8112.16421.
Any word on this? Rather hard to get the staff to use the tool if backspace is broken.
comment:16 Changed 11 years ago by
Milestone: | → CKEditor 4.1.2 |
---|
comment:17 Changed 11 years ago by
I've recently been looking into this issue as I've run into it in chrome on OSX. I've isolated it to a specific case:
If I use CKEDITOR.inline() on an element with contenteditable="true" then I can use CKEDITOR.setReadOnly(false) and backspace will work.
If however I use CKEDITOR.inline() on an element that does not have contenteditable="true" then CKEDITOR.setReadOnly(false) will leave the backspace key blocked in the keystrokeHandler.blockedKeystrokes hash.
I've attached bug.html which can be dropped into the ckeditor samples dir, this replicates the two situations described above.
comment:18 Changed 11 years ago by
Owner: | set to Olek Nowodziński |
---|---|
Status: | confirmed → assigned |
comment:19 Changed 11 years ago by
Status: | assigned → review |
---|
DEV: Created fix in t/9761 branch.
TESTS: Added tests for BACKSPACE key behavior and mt for the ticket.
comment:20 Changed 11 years ago by
Status: | review → review_passed |
---|
comment:21 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Merged into master: git:3b38fe9c4e0f6e (dev), a6c66688723eab60 (tests).
I have just checked readOnly sample in latest editor 4.0 and didn't get this problem - backspace is working as expected.
In which browsers were you getting this problem, what are steps to reproduce this, what is the code that is causing this and can this problem be reproduced in latest editor 4.0?