microsoft / microsoft/monaco-editor
[Bug] Changing content of a hidden editor and showing it again leaves the editor in a broken state
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
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
var editor = monaco.editor.create(document.getElementById("container"), {
value: "// First line\nfunction hello() {\n\talert('Hello world!');\n}\n// Last line",
language: "javascript",
});
setTimeout(function () {
editor.getDomNode().classList.add('hidden');
editor.setValue("function hello() {\n\talert('Hello world!');\n}\n");
}, 2000);
setTimeout(function () {
editor.getDomNode().classList.remove('hidden');
editor.render(true);
}, 4000);
Reproduction Steps
Run the code in the playground using Firefox or Safari.
After 2s it will hide the editor, change its content, and after another 2s it will show the editor again.
Actual (Problematic) Behavior
After the editor is shown again, it is left in a broken state, even despite the editor.render(true) call. It is impossible to place cursor or select text within a line using the mouse. Clicking on a line will always place the cursor at the end of the line.
Expected Behavior
The editor is expected to function normally in this case.
Additional Context
The issue cannot be reproduced using Chrome.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Monaco Editor Playground reproduction and compare behavior in Firefox or Safari after the editor is hidden, updated with setValue, shown, and refreshed with render(true). Trace the editor's mouse positioning and rendering behavior across that sequence; done means the restored editor allows the cursor and text selection to work normally, while Chrome behavior remains unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100