monaco-editor: Suggestion box incorrectly offset with translate animated container
When displaying monaco editor in a container that is slided into screen via translate animation, the suggestion box is offset incorrectly by (width of screen - width of container). Disabling the fixedOverflowWidgets option is not something we can do, as the suggestion box would be cut at editor length.

monaco-editor version: 0.30.0 Browser: Chrome Version 90.0.4430.93 OS: Ubuntu Playground code that reproduces the issue:
const container = document.createElement("div");
container.className = "container";
const monacoElement = document.createElement("div");
monacoElement.className = "monaco";
container.appendChild(monacoElement);
document.body.appendChild(container);
monaco.editor.create(monacoElement, {
language: 'javascript',
fixedOverflowWidgets: true,
});
.container {
width: 550px; /* increase/decrease to see offset change */
height: 100vh;
display: block;
position: fixed;
right: 0;
bottom: 0;
top: 0;
border: 1px solid black;
transform: translateX(100%);
animation: translateAnimation 1s cubic-bezier(0.19, 1, 0.22, 1) both;
}
.monaco {
width: 100%;
height: 300px;
}
@keyframes translateAnimation {
0% {
transform: translateX(100%);
} 100% {
transform: translateX(0);
}
}
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 16
- Comments: 15 (4 by maintainers)
We typically release a new editor version at the same time with a vscode release.
Sorry about that, we’re having a hiccup with the nightly build, the
0.46.0-dev-20231214doesn’t contain that change.@promeris @alexdima Fixed elements inside transformed parents are positioned relatively to those transformed parents and not the body. http://meyerweb.com/eric/thoughts/2011/09/12/un-fixing-fixed-elements-with-css-transforms You can find dozens of issues and questions on the web regarding this. I don’t think it’d be pragmatic to try to detect this case inside vscode (what if we have nested transforms 😬). For me the fix is eventually the following:
It looks like a legal way to escape transformed subtree. Anyway if you want your widgets to be fixed it doesn’t matter where exactly in DOM they will be rooted (if the root is not transformed 😅).