Skip to content

Conversation

@lattln
Copy link
Collaborator

@lattln lattln commented Jan 30, 2026

Summary

Fixes a bug where the Monaco CodeEditor auto-saved on every keystroke, causing partially typed (invalid) YAML/JSON to be parsed and normalized prematurely. This resulted in cursor jumps, duplicated fields, and lost input while typing.


Root Cause

A cleanup effect in CodeEditor.jsx depended on values that changed on each keystroke. When validation updated UI state, the effect re-ran, triggering the cleanup logic and unintentionally saving partial code.


Fix

  • Moved cleanup logic to run only on unmount
  • Stored mutable dependencies (replaceAll, ui, definition, format) in useRef
  • Updated refs on change, but read from refs during cleanup
  • Eliminated keystroke-triggered cleanup while preserving validation

Result

  • Typing no longer triggers auto-save
  • Invalid / partial YAML or JSON is allowed while editing
  • Auto-save occurs only when switching away from the editor
  • Live validation still surfaces syntax errors in the UI

Files Changed

  • CodeEditor.jsx

+ Fix a bug with auto save was depended on values that change per keystroke
+ Need further Testing
@lattln lattln linked an issue Jan 30, 2026 that may be closed by this pull request
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.

Code Editor Bug -- Unknown Cause ? schema parsing

2 participants