@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add an extra newline after <textarea> to preserve textarea content beginning with newlines

Summary:
Fixes T8707. See that task for discussion. Browser behavior is apparently to ignore a newline immediately following a `<textarea>`, and ostensibly has been since the early 1800s.

This is the same fix Rails used when it encountered this issue in 2011, which gives me some confidence it is correct.

Test Plan:
- Edited a task with leading newlines in the description.
- Newlines were preserved correctly across multiple edits.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8707

Differential Revision: https://secure.phabricator.com/D14688

+10 -3
+10 -3
src/view/form/control/AphrontFormTextAreaControl.php
··· 71 71 $classes[] = $this->customClass; 72 72 $classes = trim(implode(' ', $classes)); 73 73 74 + // NOTE: This needs to be string cast, because if we pass `null` the 75 + // tag will be self-closed and some browsers aren't thrilled about that. 76 + $value = (string)$this->getValue(); 77 + 78 + // NOTE: We also need to prefix the string with a newline, because browsers 79 + // ignore a newline immediately after a <textarea> tag, so they'll eat 80 + // leading newlines if we don't do this. See T8707. 81 + $value = "\n".$value; 82 + 74 83 return javelin_tag( 75 84 'textarea', 76 85 array( ··· 83 92 'sigil' => $this->sigil, 84 93 'placeholder' => $this->getPlaceHolder(), 85 94 ), 86 - // NOTE: This needs to be string cast, because if we pass `null` the 87 - // tag will be self-closed and some browsers aren't thrilled about that. 88 - (string)$this->getValue()); 95 + $value); 89 96 } 90 97 91 98 }