-
Notifications
You must be signed in to change notification settings - Fork 773
Fix Monaco Resizing Issue in Editor Block #2848
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
Conversation
WalkthroughResize handling for Monaco editors was centralized: Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@frontend/app/monaco/monaco-react.tsx`:
- Around line 163-175: The ResizeObserver effect creates a debounced callback
(debouncedLayout) but never cancels it on cleanup, causing pending timers to run
after unmount; update the useEffect cleanup to call debouncedLayout.cancel() (or
the cancel method your debounce implementation provides) before disconnecting
the ResizeObserver so the debounced callback created in the block that
references diffRef.current and divRef.current is properly cleared on unmount.
- Around line 76-88: The debounced callback created by debounce is not cancelled
on effect cleanup, so add cancellation before disconnecting the ResizeObserver:
call debouncedLayout.cancel() (or the cancel function returned by debounce) in
the cleanup prior to resizeObserver.disconnect() in the effect that uses
editorRef/divRef and do the same in the MonacoDiffViewer effect; if the debounce
utility doesn't expose a cancel method, update debounce to return a wrapper
function with a .cancel() method (or separate cancel function) so both effects
can call it to prevent layout() being invoked after the editor is disposed.
🧹 Nitpick comments (1)
frontend/app/view/waveconfig/waveconfig.tsx (1)
99-99:editorContainerRefappears unused after removing the ResizeObserver logic.With the resize observer moved into
monaco-react.tsx, this ref is only attached to the div (Line 159) but never read. Consider removing it to avoid confusion.🧹 Proposed cleanup
- const editorContainerRef = useRef<HTMLDivElement>(null);And on Line 159:
- <div ref={editorContainerRef} className="flex flex-col flex-1 min-w-0"> + <div className="flex flex-col flex-1 min-w-0">
No description provided.