uiwjs / uiwjs/react-codemirror

CodeMirrorMerge - Selection lost when updating

Open
#713 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
161
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked CodeSandbox and reproducing the lost selection when CodeMirrorMerge rerenders for the context menu. Compare behavior in the Original and Modified parts, including how the menu can identify its source; done means the selected code remains available and the originating part can be determined.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.