react-live icon indicating copy to clipboard operation
react-live copied to clipboard

Issue with the LiveEditor and carriage returns

Open elchininet opened this issue 2 years ago • 5 comments

I installed the new version 3.0.0 and there is an issue with LiveEditor. To reproduce the issue, it is easier if you go directly to the demo and follow these steps:

  1. Go to the Or just some JSX code! section
  2. Place the caret at the end of the code (after the last > of the h3)
  3. Try to create a new line hitting on Return
  4. A new line is created
  5. Try to remove that change with backspace key
  6. The carriage goes back but the new line is not deleted
  7. Try to delete the new line using the delete key
  8. The new line is deleted but also the parentheses is moved
  9. Try to reverse this change hitting return
  10. The parentheses goes to the new line but indented
  11. Try to remove the indentation with backspace
  12. The carriage returns to the above line

It is very hard to write code with this behaviour. Just try to code for some time in a LiveEditor of the current demo and you will notice the really bad experience.

elchininet avatar Mar 24 '22 15:03 elchininet

I did a quick test and reverting the introduction of use-editable in the Editor file solves this issue.

elchininet avatar Mar 24 '22 21:03 elchininet

Seeing this issue as well, and it's incredibly annoying for an end-user. Doesn't make for a nice experience while trying to type in some code

mryechkin avatar May 24 '22 16:05 mryechkin

As I've isolated this issue to use-editable, this issue there seems to be related:

https://github.com/FormidableLabs/use-editable/issues/17

elchininet avatar Jun 03 '22 10:06 elchininet

I noticed this as well. Here's a gif showing the bug:

bug

greypants avatar Sep 27 '22 20:09 greypants

I'm seeing similar behavior. It's very annoying. Didn't used to be like this. Debouncing the update to the LiveProvider's code prop helps a bit, but it doesn't solve the issue. Whenever the update finally gets applied to state, the cursor can sometimes (but frequently enough) get bumped a character or two, especially if the user had stopped typing is now moving the cursor around with the arrow keys (so the debounced function executes, code state updates, LiveEditor updates and problems ensue).

stefcameron avatar Mar 06 '23 20:03 stefcameron