Open
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
customElements.define(
"code-view-monaco",
class CodeViewMonaco extends HTMLElement {
_monacoEditor;
/** @type HTMLElement */
_editor;
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: "open" });
// Copy over editor styles
const styles = document.querySelectorAll(
"link[rel='stylesheet'][data-name^='vs/']"
);
for (const style of styles) {
shadowRoot.appendChild(style.cloneNode(true));
}
const template = /** @type HTMLTemplateElement */ (
document.getElementById("editor-template")
);
shadowRoot.appendChild(template.content.cloneNode(true));
this._editor = shadowRoot.querySelector("#container");
this._monacoEditor = monaco.editor.create(this._editor, {
automaticLayout: true,
language: "javascript",
value: `function hello() {
alert('Hello world!');
}`,
});
}
}
);
Reproduction Steps
- select a piece of the text
- right click the selected text
- "Copy" ( or any other action)
Actual (Problematic) Behavior
the selected text is copied but loses the focus
Expected Behavior
it should do the same as an editor not in a shadow dom(e.g.: https://microsoft.github.io/monaco-editor/playground.html?source=v0.39.0#example-creating-the-editor-hello-world) and keep the focus.
Additional Context
I believe this issue is also making it impossible to use the "Paste" action in a shadow-dom, it loses the focus as soon as you open the context menu, making it impossible to go through this condition.
But I can't reproduce it in playground because "Paste" action doesn't work at all in playground #2264
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment