uiwjs / uiwjs/react-codemirror

Readonly crashes 'RangeError: Selection points outside of document' without Editable prop

Open
#390 3 comments 2 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

Hi there!
When I'm confugiring that a user cannot write in editor, I used to use readonly prop. However, It was still possible to create selection which may point ouside of document as in Video 1, link below, HEADPHONE WARNING. However, when I also add editable prop to be editable={!isReadonly}, everything works fine, Image 1.
The props of CodeMirror is a bit confusing since it has two explicit props.

Video 1:
https://user-images.githubusercontent.com/51142471/196690444-369a156f-7e19-4c83-9daf-15977340ff9c.mp4

Image 1:

image

In the video below, because I had only readOnly={false} prop, it broke. If I add editable={!isReadOnly} prop, everything works fine.

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 reproducing the crash in the CodeMirror component using only the readOnly prop, then compare it with the editable={!isReadonly} configuration shown in the issue. Trace how those two props affect selection handling and verify that creating a selection outside the document no longer raises the reported RangeError.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.