Fix maxlength count for Feedback
What does this mr do?
Closes #693 (closed)
Actions taken to fix bug
As can be seen in the issue discussion, the JS API makes it such that when the text of the textarea is accessed, it gets normalized and newlines are only represented by '\n'. But, when the text is sent to the server-side, each newline is marked as '\r\n', thus gets counted twice. There is no way to access the raw text that is sent to the API, therefore the fix entails removing the amount of newlines in the text such that it doesn't exceed the max length on the server-side (also summarized from the html standard here).
How to test?
Try pasting this for feedback and it should allow you to save the feedback (while trimming the last 4 characters), without yielding an error:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAA
IDEA?
We have in total 9 places where we enforce a maxlength
for textareas. All of them partake in the class: "textfield". An idea would be to abstract this logic in CHIHUAHUI so that we don't write this everywhere.