Skip to content

Conversation

qirong77
Copy link
Contributor

Fix: monaco-editor issue: [Bug] error when selecting text with mouse in shadow dom
When creating the Monaco Editor using Shadow DOM, an error may occur when updating the selection, as depicted below:
Error Screenshot
The Reason:
The element retrieved from:
Element Screenshot
could potentially be the div.monaco-mouse-cursor-text element, which doesn't have any child nodes. Consequently, the following code snippet is consistently incorrect, causing the setRange method's first parameter to be null:
Error Context Screenshot
Previously, this error had been overlooked by not console:
Previous Ignored Error Screenshot
However, in a recent update where the lazy.ts was used to wrap the methods of updating the selection, this error was caught:
Recent Error Caught Screenshot 2

@ppc-harmoney
Copy link

@alexdima I don't mean to nag you, but do you have an idea of when this could be reviewed? We are seeing a lot of errors in our logging and would like this patch to be included.

Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

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

Thank you and apologies for the slow turn-around time!

@alexdima alexdima enabled auto-merge (squash) July 15, 2025 18:09
@vs-code-engineering vs-code-engineering bot added this to the July 2025 milestone Jul 15, 2025
@alexdima alexdima merged commit 2506e28 into microsoft:main Jul 15, 2025
27 of 28 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Aug 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants