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

CTRL+Z empties the content

Open supun-io opened this issue 3 years ago • 5 comments

If you focus on the editor and press CTRL+Z the content dissapears. I think this is not expected behavior. This issue happens in both v3 and v4 demos in react-codemirror.

This doesn't happen in the codemirror demo, so I think it's an issue with react-codemirror package.

Any fixes or workarounds?

supun-io avatar Feb 03 '22 16:02 supun-io

@supunkavinda I didn't reproduce your problem.

jaywcjlove avatar Feb 15 '22 10:02 jaywcjlove

  • Go to the demo: https://uiwjs.github.io/react-codemirror/
  • Focus somewhere in the code editor
  • Click Ctrl + Z. It empties the code editor

It is happening for me on Safari/Chrome/Firefox on macOS

supun-io avatar Feb 15 '22 10:02 supun-io

This is codemirror's history feature. The default display interface, the editor shows the example, and the value is changed once.

jaywcjlove avatar Feb 15 '22 10:02 jaywcjlove

Yeah, but it doesn't happen on CodeMirror demos (trying ctrl+z on these demo code editors, they don't do anything):

https://codemirror.net/ https://codemirror.net/6/

General, why should ctrl + z should empty content? 🤔

I think in react-codemirror, CodeMirror is getting the empty value as the first value.

Does that make sense?

supun-io avatar Feb 15 '22 10:02 supun-io

@supunkavinda There is no such problem in the example.

https://codesandbox.io/embed/react-codemirror-example-codemirror-6-slvju?fontsize=14&hidenavigation=1&theme=dark

jaywcjlove avatar Feb 15 '22 10:02 jaywcjlove