Strange cursor behavior when nesting editors

I’m using an extension to replace the FencedCode part with a block widget, which is also a CodeMirror editor. However, the cursor has some strange behavior when editing at the end of the paragraph in the widget.

Here is the code I wrote to minimally reproduce the problem.

The strange behavior:

ezgif.com-video-to-gif

Update:

When using a mobile phone, the editor’s cursor always jumps to the beginning of the nested editor.

ezgif.com-video-to-gif

I found this behavior to be due to bad CSS settings for the Dom in the widget, so it’s an oops.
I’m sorry if this wasted your time.