This bug is causing big layout problems for me. If a text field using CKeditor in a content type is left empty (say it's a multiple entry field and the user doesn't need to fill it in), when saved a <br /> tag is inserted. This results in extra line breaks in the displayed output. This is only happening for me in Firefox, it does not happen in either IE or Safari (haven't tried Chrome).

Has anyone else run into this? Any ideas why it's happening?

I initally thought it was related to this issue http://drupal.org/node/776026, but then I realised it was browser specific.

Any assistance much appreciated!

CommentFileSizeAuthor
#5 fix_br.patch20.08 KBgooddesignusa
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gooddesignusa’s picture

I also have this problem and wasn't sure if it was just me. This issue was way down on my list of things to look into before the site i'm working on goes live. I have yet to test if its browser specific or some setting I've set.
Have you changed the entermode to use BR's instead of P's? I know that in my settings I am using BR's

A while back ago I did some google searching on the ckeditor site and ran into this
http://cksource.com/forums/viewtopic.php?f=6&t=13353

Haven't had time to look into.

Hopefully we can work this out b/c some textareas on the site i'm working display even if empty. Since they aren't really empty. They have a BR tag and thats it.

Anonymous’s picture

I can confirm that the problem is affecting Firefox and not Safari. I visited your suggetion http://cksource.com/forums/viewtopic.php?f=6&t=13353 but there was regarding fck issue. Any idea how to solve the problem?

UPDATE: 21may2010
this is the ticket link of ckeditor development http://dev.fckeditor.net/ticket/5638

gooddesignusa’s picture

I had a little more time to experiment. I tried turning enterMode back to using p's as this was the default hoping to shine some light on where to start looking. I discovered something worth noting. This is what I did in case anyone else wants to verify.

Some background info:
I'm using FF on a mac. In drupal I have a node with some cck textareas that also use CKeditor. The body has some text in it already, some of the other textareas are empty. To be sure they were truly empty I shut off CKeditor and deleted the BR's and re saved the node before I started this test.

Making the glitch happen:
Edit the node. Click directly on "Switch to plain text editor" for the body area. Using the default settings of P you will see your body text inside a paragraph tag.
Scroll down and click on "Switch to plain text editor" for another CKEditor that is EMPTY. You will see a BR.
Clicking inside the editor first and then clicking on "Switch to plain text editor" does not cause the BR to be left behind.

Next I switched back to using BR as the entermode and redid the steps above.

Clicking on the "Switch to plain text editor" link for the CKEditor that has text in it shows just the text as expected.
Doing the same for an empty CKEditor shows a BR left behind.
Clicking inside the editor first and then clicking the "Switch to plain text editor" link still leaves a BR behind.
Clicking inside an empty editor and entering some text causes the text to jump down as if it all of a sudden notices the BR. Deleting the text and clicking the link still leaves the BR behind.

Using firebug I looked @ the code and the ckeditor has this inside an empty textarea:

<br _moz_editor_bogus_node="TRUE" _moz_dirty="">

I can also confirm that BR's are not left behind when using Safari.

gooddesignusa’s picture

After some more searching I found this file:
http://docs.cksource.com/ckeditor_api/symbols/src/plugins_wysiwygarea_pl...

And then i found this :
http://cksource.com/forums/viewtopic.php?f=11&t=18276&hilit=Firefox+BR
which has a patch opened 11 days ago. I'll test it later and report back.

gooddesignusa’s picture

FileSize
20.08 KB

So that patch was to the plugins_wysiwygarea_plugin.js file which is part of the ckeditor.js file. Fortunately the patch was a very small change and I was able to just do a search and replace inside the ckeditor.js file. The patch changes
<(p|div|address|h\d|center)[^>]*>\s*
to
(:?<(p|div|address|h\d|center)[^>]*>\s*)?

This seems to fix the issue. I tested it on a mac in FF.

I'm guessing eventually this will be committed to CKeditor. But in the mean time try out the attached patch :)

gooddesignusa’s picture

This patch fixes the BR left behind but does NOT fix the issue regarding the text getting bumped down upon initial typing. This can easily be fixed by hitting backspace before typing and isn't as big of a deal as the other issue. I assumed they were related and maybe they are. Hopefully others will chime in.

Anonymous’s picture

yes, you're right, for me is the same behaviour

willhowlett’s picture

Wow, what a great response. Many thanks for your input.

The patch certainly seems to do the trick. I'm afraid I can't seem to be able to replicate the 'shifting text' issue you describe. I'm on windows, don't know if that could be making a difference. Just clicking in the text area and typing works fine for me before and after patching.

This fix has really helped me out, and I'm glad to know it wasn't just me experiencing it. Thanks again!

gooddesignusa’s picture

willhowlett the text jumping down upon filling out an empty CKEditor textarea only happens if you using BR as a entermode. It might only happen in FF too. I haven't done any more testing since It isn't as important as the other issue. The hanging BR was really causing display issues. Hopefully someone else with some time can look into it.

bryancasler’s picture

Thanks for the BR fix, lets figure out this ghost line now.

emilyf’s picture

thank you gooddesignusa.

wwalc’s picture

Status: Active » Closed (won't fix)

This will be fixed in CKEditor 3.4, can't fix that in a module.

mseraphim’s picture

Status: Closed (won't fix) » Active

I don't really understand when you say it will be fixed in CKEditor 3.4, because I'm using 6.x-1.1 and am still having the same problem. Does anyone else have a possible solution as this is most frustrating.

amateescu’s picture

Status: Active » Closed (won't fix)

He means:

http://ckeditor.com/download

You have to update the library (ckeditor) not the drupal module.

gooddesignusa’s picture

Status: Closed (won't fix) » Active

I am no longer using this module but I am using ckeditor with the wysiwyg module. I'm using the latest version of ckeditor ( CKEditor 3.4.1, released on 21 September 2010) and I dont seem to have a problem. Since this was a fix in the actual editor it wouldn't matter if you using this module or the wysiwyg module.

jcisio’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Hanscraft’s picture

I just did the find and replace with this. The behavior has changed as so:

1) If there is no data in the CKeditor field, the field won't show at all (which is great!)
2) If I type in the CKeditor field, I then get < p > tags surrounding my text.

maaciek’s picture

Issue summary: View changes

Using CKEditor 6.x-1.1 on Drupal 6.26.

Setting CKEDITOR.config.fillEmptyBlocks to false did all the work for me.