-
Notifications
You must be signed in to change notification settings - Fork 246
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
Progress not set correctly when exceeding textarea max character limit (demo) #5
Comments
IMHO, this issue can be solved by just adding a "prgjs.set(100);" in the second branch of the textareas if construct in demo.js: this has little to do with progress.js itself.
|
That would fix the progress bar not setting correctly, but it wouldn't fix how the text "snaps" back when you let go of the key. Try holding down the key past the limit then letting go -- the extra is just lopped off abruptly, and the original cursor position lost. This is because the textarea is actually having its contents reassigned to the substring of the previous contents, which does not preserve cursor position (the lopping is because it doesn't trigger until the keyup event). A better option would be to prevent the characters past the limit from ever being inserted into the textarea by using @h3st14 You're right when you say that the issue isn't with progress.js itself -- but I'm a designer as well as a programmer, so the usability of the demo just stuck out at me. Having a good demo is important, as it shows to potential users that the problem isn't with progress.js, something they might not realize. |
Goddammit, I hate when I accidentally close things. |
I'm not sure that is the optimal solution: what if I want to insert "aaaaa" by holding my "a" key: that would be prevented, wouldn't it? Maybe the best solution is the trivial one: Setting the "maxlength" attribute of the textarea appropriately would prevent the user input after the maximum number of characters had been reached. However, I agree that some work to "make things easier" could be done. I'll take a more thorough look at the code. |
Ah, I didn't mean to say block all repeated characters, just the ones One of these days when I've got enough time I'll fork the repo and write a Sounds good!
|
@ConnorKrammer Everything goes well now? |
Thanks for the help @amerryfellow 👍 |
@afshinm I've opened a pull request that should solve the above issues fairly well. Let me know if it works for you, and if anything needs to be changed. |
Small issue with the progress bar not filling all the way on repeated text input.
To reproduce:
On a related note, it might be prudent not to allow characters to be inserted at all if the character limit is exceeded -- binding to the 'keypress' event and disallowing any keypress except the backspace key would work. Something like:
The text was updated successfully, but these errors were encountered: