Django

Code

Ticket #8627 (reopened)

Opened 2 years ago

Last modified 2 years ago

Textarea misses first line if empty (in display)

Reported by: bastih Assigned to: bastih
Milestone: Component: Forms
Version: SVN Keywords: forms textarea
Cc: Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

If you save a textarea with a leading empty line, the browser won't show you that line (when viewing that textarea a change form again). This is due to a behaviour that browsers (test FF, Safari on Mac and IE 7 on Win) ignore the first line-break within a textarea when displaying it. Therefore the patch only adds one line-break right after the opening textarea-tag

Attachments

fix_textarea_disappearing_first_empty_line.diff (4.4 kB) - added by bastih on 08/27/08 19:40:40.
Patch, only adds a line-break, with corrected tests

Change History

08/27/08 19:40:40 changed by bastih

  • attachment fix_textarea_disappearing_first_empty_line.diff added.

Patch, only adds a line-break, with corrected tests

08/27/08 19:41:36 changed by bastih

  • keywords changed from forms to forms textarea.
  • needs_better_patch changed.
  • component changed from Uncategorized to Forms.
  • needs_tests changed.
  • needs_docs changed.

(follow-up: ↓ 4 ) 08/27/08 20:14:13 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to wontfix.

I'm not sure I like this. It changes the data without the user's consent. If you load a form, then save, then load again, then save again (e.g. whilst editing), blank lines keep getting added to your data.

08/27/08 20:16:35 changed by ubernostrum

I really don't like this, because it silently corrupts the data in ways that will' screw with things people commonly use textareas for.

(as I was saying before Malcolm closed this out from under me)

(in reply to: ↑ 2 ) 08/27/08 20:58:34 changed by toke

Replying to mtredinnick:

I'm not sure I like this. It changes the data without the user's consent. If you load a form, then save, then load again, then save again (e.g. whilst editing), blank lines keep getting added to your data.

In the wild the opposite happens (At least in Safari, Firefox, IE7, Opera, lynx and others). If you rely on lets say one or two newlines in front of other data in a textarea the first newline will get eaten on every save. I have not found a current browser yet that handles this different. Opera has even changed this behavior to ignore the first line: http://my.opera.com/community/forums/topic.dml?id=94823

Use for example FlatPage? in admin enter some newlines in the textarea and then some other visible characters. Now hit "Save and continue editing" several times and watch the characters wandering upwards. In reverse entering something different to a newline will work fine. With that patch no additional newline is stored in the database.

The Spec is not 100% clear here but all major Browsers implement it on the same way. http://www.w3.org/TR/html4/interact/forms.html#h-17.7

08/27/08 21:04:31 changed by mtredinnick

  • status changed from closed to reopened.
  • stage changed from Unreviewed to Design decision needed.
  • resolution deleted.
  • milestone changed from 1.0 to post-1.0.

We can look at this after 1.0. It's too late now to have time to test it thoroughly and it's a bit of an edge case (only affects leading blank lines). I'm worried that it will change things for, e.g., machine-processed data that uses HTML intelligently.

08/28/08 08:10:36 changed by toke

For documentation: Maybe this will help with that issue when someone is working or thinking on it later: http://www.toke.de/textarea-nl-testcase.html

02/25/09 13:51:44 changed by

  • milestone deleted.

Milestone post-1.0 deleted


Add/Change #8627 (Textarea misses first line if empty (in display))




Change Properties
Action