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

[ui] Reimplement CodeMirror wrapper #16347

Merged
merged 1 commit into from
Sep 7, 2023
Merged

[ui] Reimplement CodeMirror wrapper #16347

merged 1 commit into from
Sep 7, 2023

Conversation

hellendag
Copy link
Member

Summary & Motivation

Implement our own React wrapper for CodeMirror 5. It turns out that react-codemirror2 has some bugs that appear related to React 18, so if we just set up the CodeMirror ourselves, we should be able to sidestep the existing problems and more effectively debug anything else that comes up.

This will also hopefully help set us up to upgrade to CodeMirror 6 much more easily.

In this PR, I have replaced the existing Launchpad config editor with the new implementation.

How I Tested These Changes

Using Storybook example for the new CodeMirror component, test basic text editing.

View a Launchpad in Dagster. Verify:

  • Scaffolding the config works correctly
  • The config is used properly for autocomplete
  • All basic editing behavior is correct
  • Newline entry and multiple cursors work correctly
  • Syntax highlighting is correct

@hellendag
Copy link
Member Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@hellendag
Copy link
Member Author

This is WIP-ish, since I want to do some more manual testing to make sure I haven't missed anything.

@@ -683,6 +683,7 @@ function findAutocompletionContext(

// Find context for a fully- or partially- typed key or value in the YAML document
export function expandAutocompletionContextAtCursor(editor: any) {
debugger;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eep

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeesh... this was definitely me. I'll see if we can get a linter rule forbidding these, I'm surprised it doesn't warn about them already.

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-mp3aeljgp-elementl.vercel.app
https://dish-raw-codemirror.core-storybook.dagster-docs.io

Built with commit 46e3180.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

Deploy preview for dagit-storybook ready!

✅ Preview
https://dagit-storybook-ht4b87g89-elementl.vercel.app
https://dish-raw-codemirror.components-storybook.dagster-docs.io

Built with commit 46e3180.
This pull request is being automatically deployed with vercel-action

Copy link
Collaborator

@bengotow bengotow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks great! I like the idea of just wrapping codemirror ourselves, I remember reading the react-codemirror2 source at some point and it seeming a bit whacky.

I can help test this out after it merges (or now if that'd be better)

@@ -683,6 +683,7 @@ function findAutocompletionContext(

// Find context for a fully- or partially- typed key or value in the YAML document
export function expandAutocompletionContextAtCursor(editor: any) {
debugger;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeesh... this was definitely me. I'll see if we can get a linter rule forbidding these, I'm surprised it doesn't warn about them already.

[],
);

return <StyledRawCodeMirror value={`hello\n world`} options={options} />;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh having stories for this is really nice 👍 Maybe we can add one that presents a complex YAML document too -- there are so many weird supported features in YAML it'd be nice to have an exhaustive test-case document. I can add one in a follow-up!

@hellendag
Copy link
Member Author

hellendag commented Sep 7, 2023

We've done a lot of manual testing and things look good, so I'm merging this! We can add fixes in followups as needed.

@hellendag hellendag merged commit 7fd6f47 into master Sep 7, 2023
2 checks passed
@hellendag hellendag deleted the dish/raw-codemirror branch September 7, 2023 14:49
zyd14 pushed a commit to zyd14/dagster that referenced this pull request Sep 15, 2023
## Summary & Motivation

Implement our own React wrapper for CodeMirror 5. It turns out that
react-codemirror2 has some bugs that appear related to React 18, so if
we just set up the CodeMirror ourselves, we should be able to sidestep
the existing problems and more effectively debug anything else that
comes up.

This will also hopefully help set us up to upgrade to CodeMirror 6 much
more easily.

In this PR, I have replaced the existing Launchpad config editor with
the new implementation.

## How I Tested These Changes

Using Storybook example for the new CodeMirror component, test basic
text editing.

View a Launchpad in Dagster. Verify:

- Scaffolding the config works correctly
- The config is used properly for autocomplete
- All basic editing behavior is correct
- Newline entry and multiple cursors work correctly
- Syntax highlighting is correct
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.

2 participants