Closed Bug 320006 Opened 19 years ago Closed 16 years ago

When Undo should make a textbox empty, it makes the textbox contain an (invisible) line break instead

Categories

(Core :: DOM: Editor, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 318065

People

(Reporter: bugzilla.x.jsd, Unassigned)

References

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7

If you paste a string into an html text input field, and then do an undo, the field will be left with a single newline character.

Reproducible: Always

Steps to Reproduce:
Copy this word *HELLO* to the clipboard.<br>
Then right click on the left field and select Paste.<br>
Then right click again on the left field and select Undo.<br>
<form name='f'>
<input type="text" name="input">
<input type="text" name="output">
</form>
<script>
document.f.input.addEventListener("input", oninput, true);
function oninput()
{
	document.f.output.value = escape(document.f.input.value);
}
</script>





Copy this word *HELLO* to the clipboard.<br>
Then right click on the left field and select Paste.<br>
Then right click again on the left field and select Undo.<br>
<form name='f'>
<input type="text" name="input">
<input type="text" name="output">
</form>
<script>
document.f.input.addEventListener("input", oninput, true);
function oninput()
{
	document.f.output.value = escape(document.f.input.value);
}
</script>
Assignee: nobody → mozeditor
Component: Form Manager → Editor
Product: Firefox → Core
QA Contact: form.manager
Version: unspecified → 1.7 Branch
Confirmed using Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8) Gecko/20051108 Firefox/1.5.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: PC → All
This might be what's causing bug 318355.
Summary: Undoing an input text box inserts newline (%0A) → When Undo should make a textbox empty, it makes the textbox contain an (invisible) line break instead
Version: 1.7 Branch → 1.8 Branch
QA Contact: editor
Assignee: mozeditor → nobody
Blocks: 318355
So, when an input element is empty, the editor code places a placeholder <br> element in there. When you input text, the <br> is deleted, and a text node containing the text inserted. On undo, the opposite happens.

there's some magic in nsTextEditRules::DidUndo to flag the <br> as bogus, so that it isn't converted into a linefeed when the value property of the input element is read.

However, the input event handler is invoked before this takes place, causing this behaviour.
Version: 1.8 Branch → Trunk
Someone
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.