Skip to content
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

textarea-autosize conflict with custom key bind #380

Open
joeylin opened this issue Jul 4, 2023 · 1 comment
Open

textarea-autosize conflict with custom key bind #380

joeylin opened this issue Jul 4, 2023 · 1 comment

Comments

@joeylin
Copy link

joeylin commented Jul 4, 2023

I want to a function like this: when I use shift + enter, I can wrap lines, and the textarea can autoheight,
when I use enter key, I can send the message,
BUT, when I bind the enter key to textarea(with this plugin), I found enter key was used to wrapping lines default,
Does the plugin support this feature? I understand this is a more general scenario.

thanks very much

@longlostnick
Copy link

@joeylin in case it helps I think I figured this out. You can just do an e.preventDefault(). My resulting code looks something like this:

<textarea
  onKeyDown={(e) => {
    if (!e.shiftKey && e.key === 'Enter') {
      e.preventDefault();
      handleSendMessage();
    }
  }}
/>

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

No branches or pull requests

2 participants