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

CodeMirrorMerge - Selection lost when updating

Open guillermoamaral opened this issue 7 months ago • 0 comments

Hey there,

I have implemented an IDE, being the main component of it the CodeEditor (a customized wrapper of your CodeMirror). In it, I have used onContextMenu property to manage a personalized pop-up menu providing many options (such as reference search based on selected code, etc.). Here is how it looks:

Image

When it came to provide a code-diff tool, I used CodeMerge and tried to do the same but, and here is the issue, when my component (CodeMerge) is rerendered to display the pop-up menu, the selected code is lost.

Here is an example of what I have.

Moreover, I ended up attaching the menu to CodeMirrorMerge component because (and that was my first attempt), it did not work to do it on Original and Modified parts. However, I will need to identify from which part the menu was opened to get the corresponding selected code.

Any suggestion?

Thanks in advance!

guillermoamaral avatar Jun 11 '25 12:06 guillermoamaral