microsoft / microsoft/monaco-editor
[Bug] fixedOverflowWidgets=true makes suggestion widget (Quick Fixes, Markers, Tips etc.) show at a wrong location
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
JS
function validate(model) {
const markers = [];
// lines start at 1
for (let i = 1; i < model.getLineCount() + 1; i++) {
const range = {
startLineNumber: i,
startColumn: 1,
endLineNumber: i,
endColumn: model.getLineLength(i) + 1,
};
const content = model.getValueInRange(range).trim();
const number = Number(content);
if (Number.isNaN(number)) {
markers.push({
message: "not a number",
severity: monaco.MarkerSeverity.Error,
startLineNumber: range.startLineNumber,
startColumn: range.startColumn,
endLineNumber: range.endLineNumber,
endColumn: range.endColumn,
});
} else if (!Number.isInteger(number)) {
markers.push({
message: "not an integer",
severity: monaco.MarkerSeverity.Warning,
startLineNumber: range.startLineNumber,
startColumn: range.startColumn,
endLineNumber: range.endLineNumber,
endColumn: range.endColumn,
});
}
}
monaco.editor.setModelMarkers(model, "owner", markers);
}
const value = `12345
abcd
234.56
12345
abcd
234.56`;
const uri = monaco.Uri.parse("inmemory://test");
const model = monaco.editor.createModel(value, "demoLanguage", uri);
const editor = monaco.editor.create(document.getElementById("container"), {
model,
fixedOverflowWidgets: true,
});
validate(model);
model.onDidChangeContent(() => {
validate(model);
});
HTML
<div id="root">
<div id="topspace"></div>
<div class="show-problem" style="height: 100%; overflow:hidden; position:relative;">
<div style="height: 100%; position: relative;overflow:hidden;">
<div id="container" style="height: 100%;">
</div>
</div>
</div>
</div>
CSS
body {
height: 100%;
width: 100%;
max-width: 100%;
}
.show-problem {
transform: translate(0px);
filter: drop-shadow(0 2px 1px rgb(0 0 0 / 0.05));
}
#root {
display: grid;
grid-template-rows: auto 1fr auto;
padding-left: 100px;
height: 100%;
width: 100%;
background-color: yellow;
}
#topspace {
width: 100%;
height: 200px;
background-color:red;
}
Reproduction Steps
See the code in the playground. Of importance:
Set the fixedOverflowWidgets option to true. And make sure that the show-problem class is on the div and the class has styles as follows:
.show-problem {
transform: translate(0px);
filter: drop-shadow(0 2px 1px rgb(0 0 0 / 0.05));
}
Actual (Problematic) Behavior
With the configuration as provided in the playground sample, when you hover over the markers placed in the editor, the suggestion widget gets displayed at a wrong position far from the hovered marker. This position depends on the spacing on the left and top in the yellow and red areas. If you increase the width/height of those areas by changing the padding and/or height, the suggestion widget position also moves accordingly.
This problem only happens if you include the styles that are included in the show-problem class, namely the filter and transform. Any one of them is enough to trigger the problem. Remove the show-problem class and the problem goes away and the suggestion widget gets displayed at the expected position when you hover over the text with markers.
Expected Behavior
Suggestion widget should always display at correct position.
Screenshot is with the show-problem class removed from the div.
Additional Context
This is related to: https://github.com/microsoft/monaco-editor/issues/2503
@hediet asked for a repro sample. ask and you shall receive.
Problem still exists in version 0.52.0.
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
Use the linked Monaco Editor Playground reproduction first; toggle fixedOverflowWidgets and the show-problem transform/filter styles to confirm the offset. Trace the positioning path for suggestion and marker widgets, then verify the widget stays aligned when those styles and surrounding spacing are present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100