Bug in Mozilla Editor - <br> tags in HTML source

In my "Initial experiences with Mozilla Firebird and Radio" (Sep. 09), I described some of the problems and issues I was running into trying to use Mozilla Firebird to create and edit posts.

This is one of the problems that was really annoying me:

2. While I was trying to delete the above mentioned characters, the Mozilla editor seemed to get confused at times about what text I was trying to edit. The blinking cursor would be at a specific position in the html code, and when I pressed the BackSpace or Del key, the character that would be deleted was one character to the left of the character that should have been deleted.

This problem occurred when I was editing in "View HTML Source" mode. Initially, I thought it was a bug in the code Radio uses to control the editor, but I no longer believe this is the case.

This problem appears to be caused by the way the Mozilla editor inserts tags into the code when a user presses the Enter key. When the Enter key is pressed, the Mozilla Editor actually inserts "<br> " (a <br> tag plus a space). When the user then switches the editor into "View HTML Source" mode, these extra space characters are not accounted for when the Mozilla Editor calculates the actual character position to be edited. Text editing occurs one character position to the left of the blinking cursor for every <br> tag (and extra space) present between the beginning of the text and the location of the blinking cursor.

Here is an example to demonstrate this bug:

Open the Desktop Website in Mozilla Firebird, and enter the following in the editor window:

Now is the

time for all

good men to

come to the

aid of their

country.

The source code for this text should look something like the following (which you can see by selecting the text, then right click on the selected text and click "View Selection Source":

Now is the<br>
<br>
time for all<br>
<br>
good men to<br>
<br>
come to the<br>
<br>
aid of their<br>
<br>
country.<br>

Check on the "View HTML Source" box to view the source code in the editor. You should see something like this:

Now is the<br> <br> time for all<br> <br> good men to<br> <br> come to the<br> <br> aid of their<br> <br> country.<br>

Notice the extra spaces after each <br> tag.

Click the mouse somewhere in the middle of the source code and type or delete some characters. The character that is typed or deleted will not be the one at the blinking cursor position. The number of characters it is off should be the number of <br> tags (extra spaces) between the cursor and the beginning of the HTML code.

This does not appear to be a bug in Radio - I think it is a bug in the editor itself. Unfortunately, this bug makes the Mozilla Editor pretty useless for editing the HTML source code of posts.

One other nitpick I have with the editor: Pressing the Enter key should create <p> tags, not <br> tags. If a user wants a <br> tag, press shift-Enter. I did not see any way to create a new paragraph except for editing the HTML source code.

About this Entry

This page contains a single entry by TweezerMan published on September 25, 2003 12:53 AM.

Yet more Radio tweaking - font colors in the HTML editor was the previous entry in this blog.

Setting display colors in Radio's HTML editor - Part 1 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 6.1.2

MT-Vampire plugin

web hosting by TotalChoice Hosting

Valid XHTML 1.0!
Valid CSS!