mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
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
This commit is contained in:
parent
75f126c3d0
commit
ec71dcd8e9
1 changed files with 10 additions and 3 deletions
|
@ -71,6 +71,15 @@ class AphrontFormTextAreaControl extends AphrontFormControl {
|
|||
$classes[] = $this->customClass;
|
||||
$classes = trim(implode(' ', $classes));
|
||||
|
||||
// NOTE: This needs to be string cast, because if we pass `null` the
|
||||
// tag will be self-closed and some browsers aren't thrilled about that.
|
||||
$value = (string)$this->getValue();
|
||||
|
||||
// NOTE: We also need to prefix the string with a newline, because browsers
|
||||
// ignore a newline immediately after a <textarea> tag, so they'll eat
|
||||
// leading newlines if we don't do this. See T8707.
|
||||
$value = "\n".$value;
|
||||
|
||||
return javelin_tag(
|
||||
'textarea',
|
||||
array(
|
||||
|
@ -83,9 +92,7 @@ class AphrontFormTextAreaControl extends AphrontFormControl {
|
|||
'sigil' => $this->sigil,
|
||||
'placeholder' => $this->getPlaceHolder(),
|
||||
),
|
||||
// NOTE: This needs to be string cast, because if we pass `null` the
|
||||
// tag will be self-closed and some browsers aren't thrilled about that.
|
||||
(string)$this->getValue());
|
||||
$value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue