-
Notifications
You must be signed in to change notification settings - Fork 218
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
Using "Enter" to add a new line does not work as expected #182
Comments
What browser are you using ? Do you observe this behavior only when the contenteditable element is is managed by react-contenteditable ? |
I edited my post with the browser version.
I did not try to manage a contenteditable without it, I wanted to avoid doing that by using this library. |
I just give it a quick try, using |
Bon, essayons en français 😛 Quel navigateur utilisez-vous ? Firefox, chrome, safari... ? Et quelle version ? Pouvez-vous créer un élément avec la propriété contenteditable en dehors de react-contenteditable, et indiquer si vous constatez le même problème ? |
ça ne changera pas vraiment ma réponse, je pense que c'était compréhensible :(
J'ai édité mon post avec la version du navigateur, à savoir Chrome v78.
J'ai essayé rapidement de créer une |
I just figure out that it was because of a "display: flex". |
My bad.. the bug is still present. |
@llccrr , I had the same problem. Reason (in my case): during every re-render |
My solution involves using <ContentEditable
onKeyDown={(event) => {
if (event.key === 'Enter') {
document.execCommand('insertLineBreak')
event.preventDefault()
}
}}
/> |
I tried the library using this codesandbox: https://codesandbox.io/s/l91xvkox9l
If I use
Shift + Enter
to add a new line it works.If I use
Enter
to add a new line, then click away to on blur it, it removes lines that were created.Basically:
"AAAAA
aa
AA"
becomes "AAAAAaaAA"
browser:
Chrome - version 78.0.3904.97
The text was updated successfully, but these errors were encountered: