question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using "Enter" to add a new line does not work as expected

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
morintedcommented, Aug 13, 2020

My solution involves using white-space: pre-wrap; and then controlling the enter key in order to prevent the insertion of div/p:

<ContentEditable
    onKeyDown={(event) => {
        if (event.key === 'Enter') {
          document.execCommand('insertLineBreak')
          event.preventDefault()
        }
      }}
/>
8reactions
lovasoacommented, Nov 25, 2019

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 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enter Key Not Skipping Line--HELP!! - Microsoft Community
Hi, The Enter key is not to move down the page or start a new line. In Word, it is to end a...
Read more >
New Line '\n' is not working in Typescript - Stack Overflow
I am creating a list item in typescript component ...
Read more >
Enter key does not work as expected in RDp and RDi LPEX ...
When the Enter key is used in the LPEX editor for COBOL it does not do the split as expected. Instead it moves...
Read more >
Pressing Enter Key gives space instead of newline - Super User
To fix this, I had to open a new document, then copy and paste the text. Make sure not to copy and paste...
Read more >
Adding a Newline Character to a String in Java - Baeldung
We can also use Unicode characters “& #13;” (Carriage Return) and “& #10;” (Line Feed). Although these characters work, they don't work exactly ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found