Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
indicozy opened this issue Oct 19, 2022 · 3 comments

Comments

@indicozy
Copy link

indicozy commented Oct 19, 2022

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.

@indicozy
Copy link
Author

indicozy commented Oct 20, 2022 via email

@fr1n63
Copy link

fr1n63 commented Nov 25, 2022

Seeing the same issue - readonly doesn't stop key commands being sent to the editor. You only see the cursor move if you type in the middle of a doc, but if you type at the end new characters are appended to the doc and the error shows.

work around

onKeyDown={(event) => readOnly && event.preventDefault()}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants