View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0025839||mantisbt||html||public||2019-06-04 13:17||2019-06-14 07:12|
|Target Version||2.22.0||Fixed in Version||2.22.0|
|Summary||0025839: Leading newlines disappear when editing data in textarea elements|
if you write in e.g. steps_to_reproduce:
|Tags||No tags attached.|
Not sure I understand what you mean. We trim whitespace prior to saving, so any leading newlines would be removed, this is normal and expected behavior.
I have tested it on 2.21
so the first new line is missing.
OK, I see what you mean now. Looks like Mantis is somehow removing a single newline from the text, each time the issue is updated.
What confused me was
But in fact in view issue page (view.php) you there are no leading newlines at all (as shown in attached screensot).
screenshot-20190605-1529.png (1,428 bytes)
screenshot-20190605-1529.png (1,428 bytes)
So on our mantis new line at the beginning is not removed and is stored with new lines in DB.
The newlines are stored in the DB exactly as you typed them when you click the Submit / Update button. They are only hidden on display (due to the fact that HTML ignores whitespace).
The behavior you're experiencing is a consequence of the HTML5 specification (look under A start tag whose tag name is "textarea" , emphasis mine):
To fix this, we'd have to update the markup everywhere we use textareas, to add a newline after the opening tag.
Please see PR https://github.com/mantisbt/mantisbt/pull/1518
Kindly test and let me know your feedback, either here or in the PR.
As for me, it is OK, but wouldn`t be better to change it in the string_textarea function?
Thanks for the feedback.
string_textarea() deals with display, so I don't think modifying it would be the right way to fix this issue.
The problem as I see it, is about storage : MantisBT should not alter data (i.e. text should be stored exactly as the user entered it). Currently due to the behavior defined by HTML 5 spec, we are removing one newline every time a textarea is edited and then saved, until there are no more. That's what I covered in the PR.
I would expect that the behavior should be to trim text box and text area values before adding them to the database. This would make view and edit behavior consistent, while removing extra blank lines before/after text.
This would mean we have also to trim data entered via SOAP or REST API (hardly a good idea).
so +1 for
MantisBT: master d975045e
2019-06-05 12:40:27Details Diff
|Add newline after <textarea> tags
The HTML 5 specification states that "Newlines at the start of textarea
elements are ignored as an authoring convenience." 
To avoid altering user data (e.g. issue description, steps to reproduce,
etc.) having leading newline(s) when editing and saving, the markup of
all pages displaying user content in textarea tags has been modified to
add a newline after the opening tag.
|mod - account_prof_edit_page.php||Diff File|
|mod - bug_report_page.php||Diff File|
|mod - bug_update_page.php||Diff File|
|mod - manage_columns_inc.php||Diff File|
|mod - manage_custom_field_edit_page.php||Diff File|
|mod - manage_proj_edit_page.php||Diff File|
|mod - manage_proj_ver_edit_page.php||Diff File|
|mod - news_edit_page.php||Diff File|
|mod - proj_doc_edit_page.php||Diff File|
|mod - tag_update_page.php||Diff File|
|2019-06-04 13:17||TomekAP||New Issue|
|2019-06-05 04:49||dregad||Status||new => feedback|
|2019-06-05 04:49||dregad||Note Added: 0062197|
|2019-06-05 05:20||TomekAP||Note Added: 0062202|
|2019-06-05 05:20||TomekAP||Status||feedback => new|
|2019-06-05 09:40||dregad||File Added: screenshot-20190605-1529.png|
|2019-06-05 09:40||dregad||Note Added: 0062206|
|2019-06-05 09:51||TomekAP||Note Added: 0062208|
|2019-06-05 11:47||dregad||Note Added: 0062211|
|2019-06-05 12:45||dregad||Note Added: 0062212|
|2019-06-05 12:45||dregad||Assigned To||=> dregad|
|2019-06-05 12:45||dregad||Status||new => assigned|
|2019-06-05 15:59||TomekAP||Note Added: 0062213|
|2019-06-06 05:40||dregad||Note Added: 0062217|
|2019-06-07 03:26||dregad||Summary||New line problem in HTML => Leading newlines disappear when editing data in textarea elements|
|2019-06-11 02:16||vboctor||Note Added: 0062235|
|2019-06-11 17:18||atrol||Note Added: 0062241|
|2019-06-14 07:11||dregad||Changeset attached||=> MantisBT master d975045e|
|2019-06-14 07:11||dregad||Status||assigned => resolved|
|2019-06-14 07:11||dregad||Resolution||open => fixed|
|2019-06-14 07:11||dregad||Fixed in Version||=> 2.21.2|
|2019-06-14 07:12||dregad||Fixed in Version||2.21.2 => 2.22.0|
|2019-06-14 07:12||dregad||Target Version||=> 2.22.0|