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

Disable multiline Input #150

Open
LazerJesus opened this issue Feb 20, 2019 · 3 comments
Open

Disable multiline Input #150

LazerJesus opened this issue Feb 20, 2019 · 3 comments

Comments

@LazerJesus
Copy link

Is it possible to disable mulitline Input?
Meaning, no breaks. And when the user presses return while typing, nothing happens.

@ericmurphyxyz
Copy link

You can just add onKeyDown={e => e.keyCode === 13 && e.preventDefault()} to your ContentEditable component.

@zomars
Copy link

zomars commented Mar 20, 2019

@ericnmurphy but this doesn't prevent someone pasting in line breaks, or does it?

@iamandrewluca
Copy link

iamandrewluca commented Jul 1, 2019

I use this code to keep single line

onChange={e => {
  // strip html
  const node = document.createElement('div')
  node.innerHTML = e.target.value
  const value = node.innerText.replace(/(?:\r\n|\r|\n)/g, ' ')
  this.onChange(value)
}}

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

4 participants