Skip to content

[Bug] error when selecting text with mouse in shadow dom #4548

@hungtcs

Description

@hungtcs

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

Link To Monaco Playground

Monaco Editor Playground Code

const defaultValue = `async function main() {
  // select this text with the mouse and an error will appear in the console
}
main().catch((err) => console.error(err))
`;

class MyElement extends HTMLElement {
	constructor() {
		super();
		const shadowRoot = this.attachShadow({ mode: "open" });
		const styleLink = document.createElement('link');
		styleLink.rel ='stylesheet';
		styleLink.href = 'node_modules/monaco-editor/min/vs/editor/editor.main.css'
		shadowRoot.appendChild(styleLink);
	}

	connectedCallback() {
		const conatiner = document.createElement("div");
		conatiner.style.width ='100%'
		conatiner.style.height ='320px'
		conatiner.style.resize ='both'
		conatiner.style.overflow ='hidden'
		this.shadowRoot?.appendChild(conatiner);
		
		monaco.editor.create(conatiner, {
			value: defaultValue,
			theme: 'vs-dark',
			language: "javascript",
			automaticLayout: true,
		});
	}
}

customElements.define('my-element', MyElement);

Reproduction Steps

  1. Select the text in editor with the mouse
  2. An error will appear in the console

Actual (Problematic) Behavior

An error occurred in the console

image

Expected Behavior

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions