Fix: prevent keyup propagation from Monaco editor triggering false dirty state (#1495)#1498
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe CodeEditor form widget's attachListeners() method now registers a capture-phase keyup event listener on the Monaco editor's DOM node that stops event propagation. This prevents keyup events from bubbling up to jQuery, which previously caused forms to be incorrectly marked as "dirty" when keys such as Command (macOS) were pressed inside the editor without actual content changes. Estimated code review effort: 1 (Trivial) | ~2 minutes Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant EditorDomNode
participant jQuery
User->>EditorDomNode: keyup event
EditorDomNode->>EditorDomNode: stopPropagation (capture phase)
EditorDomNode-->>jQuery: event blocked
Related issues: Suggested labels: bug, backend, javascript Suggested reviewers: none identified Poem 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #1495
Summary
On macOS, pressing the Command key alone while focused on the backend Code Editor (Monaco Editor) incorrectly marks the form as "dirty" (unsaved changes), even though no content was edited.
Root cause
keyupevents fired inside the Monaco Editor's DOM node bubble up and are captured by jQuery, which triggers the backend form's dirty-state handler.Fix
Stop the propagation of
keyupevents at the editor's DOM node level. This prevents unrelated key events (such as pressing Command alone) from reaching the form's dirty-state handler, while actual content edits still flow through Monaco'sonDidChangeContentevent as before:Monaco model change → CodeEditor input event → Winter CMS dirty state
Testing
Note on compiled assets
I attempted to run
mix:compilelocally to update the compiled bundle, but this produced a large number of unrelated changes (chunk naming, minified worker files) likely due to differences between my local Node/webpack environment and the one used to produce the current build. To keep this PR focused and reviewable, I've only included the source change incodeeditor.js.Summary by CodeRabbit
keyupevents are no longer intercepted by surrounding page behavior while editing.