Welcome to Codidact Meta!
Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.
Comments on Handling too short comments padded with spaces
Post
Handling too short comments padded with spaces
When starting a new comment thread, the "Create thread" button is disabled until the content of the "Your comment" text box has at least 15 characters. This character count includes leading and trailing spaces. However, leading and trailing spaces are removed after pressing "Create thread", which can make the comment become too short to be accepted, not necessarily due to any fault of the user[1].
When this problem occurs when adding a new comment to an existing thread, a red error message is displayed above the thread, so the user can try again:
This is helpful, but the original message is removed so rather than typing an extra character, the user has to type out the whole message from scratch.
There is a larger problem when creating a new thread (rather than adding a comment to an existing thread). Instead of a helpful red message, there is just a 422 error page and no text box for the user to try again. This gives no indication of what went wrong:
I have 2 suggestions to improve the user experience:
- Introduce the same behaviour for new threads as currently exists for new comments in existing threads: A red message making clear what went wrong ("Content is too short (minimum is 15 characters)" rather than a 422 page), and a text box allowing the user to try again.
- When the user is given the opportunity to try again, provide the previously entered text so the user does not have to type it all out again.
Better still would be to measure the comment length in a consistent way so that the mismatch does not happen. This could be done by deciding whether to enable the button based on the comment text stripped of any leading and trailing whitespace, rather than based on the full comment text. This way any text accepted by the front end (browser) will also be accepted by the back end (server).
I would expect this to be easier to implement than the 2 suggestions shown above, and better for the user, but the other 2 suggestions might still need to be implemented for users with JavaScript disabled in their browser.
-
In some cases this will be due to a user deliberately adding spaces to try to get around the 15 character minimum. However, this can also happen accidentally, particularly on mobile where the on screen keyboard adds a space after each word. A user may not always realise that their 14 character message has an automatically added space at the end bringing it up to 15 characters. ↩︎
1 comment thread