codidact / qpixel

Q&A-based community knowledge-sharing software
https://codidact.com
GNU Affero General Public License v3.0
397 stars 68 forks source link

prevent validation errors when creating too-short new comment threads #1378

Open cellio opened 3 months ago

cellio commented 3 months ago

meta:291094

Comments have a minimum length before the "post" button is enabled. This check includes leading/trailing whitespace, but such whitespace is trimmed on submission and that can make the comment now too short. In that case, you get either a red-box error or a 422 (with your comment gone), which is not good.

From the user perspective the best thing to do would be to apply that "trim" logic when checking to see whether to allow posting. I don't know if that's expensive (since it has to be checked frequently as you type).

If that's not practical, then can we catch the problem in-page, so you get a message saying "too short after all, sorry" and your draft is still there so you can keep editing?