Skip to content

Conversation

@ramezgerges
Copy link

GitHub Issue: closes unoplatform/uno#22144

PR Type:

What is the current behavior? πŸ€”

What is the new behavior? πŸš€

PR Checklist βœ…

Please check if your PR fulfills the following requirements:

Other information ℹ️

Copilot AI review requested due to automatic review settings December 16, 2025 18:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue with Monaco Editor sizing on WASM by replacing manual layout refresh calls with automatic parent element size tracking using ResizeObserver. Instead of relying on explicit LayoutUpdated events and window resize listeners, the editor now observes its parent element directly and adjusts layout automatically when size changes occur.

Key Changes:

  • Replaced window resize listener with ResizeObserver for more reliable size tracking
  • Removed C# LayoutUpdated event handler that triggered manual layout refreshes
  • Removed the RefreshLayout JSImport method and its manual invocations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
MonacoEditorComponent/ts-helpermethods/asyncCallbackHelpers.ts Replaced window resize listener with ResizeObserver to track parent element size changes; removed manual layout calls
MonacoEditorComponent/CodeEditor/CodeEditorPresenter.wasm.cs Removed LayoutUpdated event handler, RefreshLayout JSImport method, and manual layout refresh calls

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +71 to 72
resizeObserver.observe(element);

Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The ResizeObserver created here is never disconnected, which can lead to a memory leak if the editor element is removed from the DOM. Consider storing the ResizeObserver instance in the EditorContext and disconnecting it when the editor is destroyed or disposed. You should call resizeObserver.disconnect() in a cleanup method.

Suggested change
resizeObserver.observe(element);
resizeObserver.observe(element);
// Store the observer on the editorContext for later cleanup
editorContext._resizeObserver = resizeObserver;
// Add a dispose method to editorContext to clean up resources
editorContext.dispose = function() {
if (this._resizeObserver) {
this._resizeObserver.disconnect();
this._resizeObserver = null;
}
if (this.model && typeof this.model.dispose === "function") {
this.model.dispose();
}
if (this.Accessor && typeof this.Accessor.dispose === "function") {
this.Accessor.dispose();
}
if (this.Keyboard && typeof this.Keyboard.dispose === "function") {
this.Keyboard.dispose();
}
if (this.Theme && typeof this.Theme.dispose === "function") {
this.Theme.dispose();
}
if (this.Debug && typeof this.Debug.dispose === "function") {
this.Debug.dispose();
}
if (editor && typeof editor.dispose === "function") {
editor.dispose();
}
};
// NOTE: You must call editorContext.dispose() when cleaning up the editor to avoid memory leaks.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 20, 2026 17:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Resizing native element in WASM is behind by a frame, leaving a gap

3 participants