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
Prevent autosize manually? #272
Comments
Have you attempted this already? I don't see why either of those things would cause autosize to trigger. |
...not following. Just press enter on an autosize. It will increase the size of the box... |
Maybe the confusion stems from the fact that I'm using a remote form? There is no page refresh. So the textarea remains larger due to the enter key press. |
I'm going to say no, because this doesn't seem like something the script should have to account for. Forms aren't normally submitted when pressing enter, if a textarea is receiving input. |
I respectfully disagree... Check out facebook on a desktop. Type a comment and press enter. The form is submitted. |
Regardless of our opinions on how apps should function, I'm simply asking if there is a way to "preventDefault", so to speak, in certain cases. Simple question, seems like the answer is no. If not I can take a look at the source code and see if I can figure out the easiest way to implement something like that. |
That's not browser default behavior for submitting forms, it's not really a matter of opinion. But, I see what you are getting at. You could bind to the keydown event to prevent the default action, which should prevent textarea from receiving an input event (this is what autosize is listening to). For example:
|
Excellent, thanks for the help. I was doing e.preventDefault, but hooking into the wrong place, so it wasn't actually preventing autosize from firing. I bet this will do the trick. Cheers! |
I actually had it pretty close in the first place, it was only a matter of changing 'keyup' to 'keypress'. Thanks for helping me track that down. |
Is it possible to manually prevent autosize from triggering?
I would do this in an if statement for certain cases (for example, I'm submitting the form on the enter key, and I don't want it to resize the box in that case...or display a modal saying 'you didn't enter anything' if the textarea is blank). Both cases I don't want autosize to fire.
The text was updated successfully, but these errors were encountered: