diff options
| author | netop://ウィビ <paul@webb.page> | 2026-04-24 17:57:26 -0700 |
|---|---|---|
| committer | netop://ウィビ <paul@webb.page> | 2026-04-24 17:57:26 -0700 |
| commit | 41eef08bc409ba2a5a49e7d785bd113da51bab23 (patch) | |
| tree | ce45faaafcded4e7b8de1154db5270203926c164 /source/library | |
| parent | 216441d3564e00aabfac7e8acf346e34a5db9598 (diff) | |
| download | graphiql-41eef08bc409ba2a5a49e7d785bd113da51bab23.tar.gz graphiql-41eef08bc409ba2a5a49e7d785bd113da51bab23.zip | |
Push value prop changes into Editor's CodeMirror state
Editor read the value prop once at mount and never reconciled later
mutations into the CodeMirror doc. Result viewer never showed query
output, format button output never reached the editor, and history
loads stayed invisible. Add an effect that diffs the doc against the
incoming value and dispatches a replacement transaction when they
differ — guard against the user-typing echo by skipping when they
already match.
Diffstat (limited to 'source/library')
| -rw-r--r-- | source/library/components/Editor.svelte | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/library/components/Editor.svelte b/source/library/components/Editor.svelte index 393812a..073a76a 100644 --- a/source/library/components/Editor.svelte +++ b/source/library/components/Editor.svelte @@ -115,6 +115,18 @@ // Invalid SDL — silently skip; editor keeps working without schema awareness } }); + + $effect(() => { + if (!view) + return; + + if (view.state.doc.toString() === value) + return; + + view.dispatch({ + changes: { from: 0, insert: value, to: view.state.doc.length } + }); + }); </script> <style lang="scss"> |