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

Fix editable CodeBlock #2239

Merged
merged 2 commits into from
Jul 29, 2024
Merged

Fix editable CodeBlock #2239

merged 2 commits into from
Jul 29, 2024

Conversation

laurakwhit
Copy link
Contributor

Description & motivation 💭

Sets CodeMirror EditorView.editable based on editable prop in CodeBlock component in addition to EditorState.readOnly.

Screenshots (if applicable) 📸

Design Considerations 🎨

Testing 🧪

How was this tested 👻

  • Manual testing
  • E2E tests added
  • Unit tests added

Steps for others to test: 🚶🏽‍♂️🚶🏽‍♀️

Checklists

Draft Checklist

Merge Checklist

Issue(s) closed

Docs

Any docs updates needed?

@laurakwhit laurakwhit requested a review from rossedfort as a code owner July 26, 2024 21:08
Copy link

vercel bot commented Jul 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
holocene ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2024 9:15pm

@laurakwhit laurakwhit requested a review from a team as a code owner July 26, 2024 21:14
@laurakwhit laurakwhit requested review from KATIETOLER and removed request for a team July 26, 2024 21:14
@Alex-Tideman
Copy link
Contributor

Kinda confused by this, is this a bug in CodeMirror? We shouldn't need two configurations to make it readOnly.

Also not seeing this same behavior on OSS. Do we just need to set this on Cloud?

@rossedfort
Copy link
Contributor

rossedfort commented Jul 29, 2024

Kinda confused by this, is this a bug in CodeMirror? We shouldn't need two configurations to make it readOnly.

Also not seeing this same behavior on OSS. Do we just need to set this on Cloud?

I think it was a bug in CodeMirror codemirror/dev#1411

Also, it appears readonly and editable are actually 2 different things according to CodeMirror. If you look at a Holocene preview link before the bug was introduced, notice you can click inside the CodeBlock to drop a cursor, but you can't type/delete anything. This was when we were just doing EditorState.readOnly.of(!editable). If you look at the Holocene preview link for this PR, notice you can't even drop a cursor in the CodeBlock.

We probably could just use EditorView.editable.of(editable) instead of EditorState.readOnly.of(!editable), but I think this fine.

@laurakwhit laurakwhit merged commit a638bce into main Jul 29, 2024
14 checks passed
@laurakwhit laurakwhit deleted the fix-editable-code-block branch July 29, 2024 15:39
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

Successfully merging this pull request may close these issues.

3 participants