Skip to content

[$50] Max message length handling #535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jmgasper opened this issue Apr 5, 2021 · 12 comments
Closed

[$50] Max message length handling #535

jmgasper opened this issue Apr 5, 2021 · 12 comments

Comments

@jmgasper
Copy link
Collaborator

jmgasper commented Apr 5, 2021

To go along with #483 , we need to also handle the case where the message is too long (over the max).

We'll have the display as the same - red rectangle around the text area with a message in red below: Comment is XXXX characters too long

@jmgasper
Copy link
Collaborator Author

jmgasper commented Apr 5, 2021

Challenge https://www.topcoder.com/challenges/f5f96124-617d-411d-940d-6f1d91e9db84 has been created for this ticket.

This is an automated message for ghostar via Topcoder X

@jmgasper
Copy link
Collaborator Author

jmgasper commented Apr 5, 2021

Challenge https://www.topcoder.com/challenges/f5f96124-617d-411d-940d-6f1d91e9db84 has been assigned to obog.

This is an automated message for ghostar via Topcoder X

@atelomycterus
Copy link
Collaborator

@jmgasper Please apply PRs:
#536
topcoder-platform/forums-topcoder-editor-plugin#18
topcoder-platform/forums-theme#35

Thanks!

Testing

Please clear browser cache before testing.

Adding a new comment:
image

Editing a comment
image

@jmgasper
Copy link
Collaborator Author

jmgasper commented Apr 5, 2021

Payment task has been updated: https://www.topcoder.com/challenges/f5f96124-617d-411d-940d-6f1d91e9db84
Payments Complete
Winner: obog
Copilot: ghostar
Challenge f5f96124-617d-411d-940d-6f1d91e9db84 has been paid and closed.

This is an automated message for ghostar via Topcoder X

@sdgun
Copy link
Collaborator

sdgun commented Apr 6, 2021

@atelomycterus I entered a long text(characters 15946 according to https://www.charactercountonline.com/)
long text.txt, the comment text field is outlined in red and shows the error message "Comment is 2 characters too long". Then I deleted two characters so the red outline disappears but it shows the error "Body is 56 characters too long." on top of the editor in the red banner. Because of this, the comment cannot be posted too.

Screencast.2021-04-06.mp4

@jmgasper
Copy link
Collaborator Author

jmgasper commented Apr 6, 2021

@atelomycterus ☝️

@jmgasper jmgasper reopened this Apr 6, 2021
@sdgun sdgun removed the Ready for QA label Apr 8, 2021
@atelomycterus
Copy link
Collaborator

@sdgun I'll check how Vanilla counts comment body length on the server side. Keep you updated.

@atelomycterus
Copy link
Collaborator

atelomycterus commented Apr 9, 2021

@jmgasper Fixed for a comment form. I'll fix validation rules for discussion from in #538. I added some details about special characters.

Please apply PRs:

Thanks!

Special characters

15946 according to https://www.charactercountonline.com/
16058 according to Notepad++.
16002 according textarea (Topcoder editor)

CR and LF are special characters (ASCII 13 and 10 respectively, also referred to as \r\n) that are used to signify the End of Line (EOL).

All characters are displayed in Notepad++:
image

https://www.charactercountonline.com/ ignores CRLFs (2x56).

The comment text field is outlined in red and shows the error message "Comment is 2 characters too long".

On client, "Comment is 2 characters too long" was displayed because as per the HTML5 specification, textarea uses the LF character for new lines (\n), but it also understands and internally transforms \r and \r\n. To count for the CRLF character pair, need to replace LF with CRLF, before the comment form is validated.

Then I deleted two characters so the red outline disappears but it shows the error "Body is 56 characters too long."

All characters are counted on the server side.

image

Notepad
image

Testing

Please clear browser cache before testing.
Testing with text from the attached file:
image

@jmgasper
Copy link
Collaborator Author

@sdgun ☝️

@sdgun
Copy link
Collaborator

sdgun commented Apr 12, 2021

Verified in Dev.

@atelomycterus
Copy link
Collaborator

@sdgun
Copy link
Collaborator

sdgun commented Apr 27, 2021

Verified in Dev with #538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants