[Bug] Tooltips are placed too high when the host page is scrolled

Open
#5,515 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@benibenj is already working on this.

Since Oct 7, 2026.

Assessment

This issue has not been assessed yet.

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?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.57.0#XQAAAAK9AgAAAAAAAABBqIlHNxBRloqNA_hKgZMXenREjOaGX1OdQfpIzlcLAKKGNszIdJiKbICCfKhDdW7YlvvFCoiLK9i5Y2BQAfUeMP4ItBAnRe9II-C2PYV8OeYb_JaS2NDibMvYg_LfPtbS7Y5eZ2ljOJGTmdYCnJeIV8kDQ5SZ3WYAFiVMFBWQLefhglExdYTFY-1x1VsCy03KH8EyrgGQQs1x0nSDVh9Xi6HZIMz3I2aMhOO_hlXioeIAfAHYWM98R-AT8SBNUj_rpPJHOwZLbz8CUnui2cbnk8tWSkwF0AzjgeDqPb-2EnOizh711Yx9HINs6dAi79YFOKTI95QAXZyNSsd5BmS3KqY7SB-7RFn048A2LW8Ix4hHmVlyKePVrdF44AlvocXc4fY2_RLooPMbh9KMoWn6mH-uXicKK0g_8D30rE_EBzXNepqYGBY-cJu2wIChFVLX0w7g3Cw2W_LpY5znKirU9dt6_Q-rtQeRwydJnUq-rzQE68Lbd0l1gW--_pdlTqXTIigT3g8RCMl8Kxppbacx42hhh844AJdlHIPTnS20HaQ8CbsD6KiiHyQLSCtmEmXSOv_vbMWorf86czWL_0Gu7QA

Monaco Editor Playground Code

HTML:

<div style="height: 150vh"></div>
<div id="container" style="height: 300px; border: 1px solid #888"></div>
<div style="height: 150vh"></div>

CSS:

/* let the page scroll (the playground runner disables it) */
html, body { height: auto; overflow: auto; }

JS:

const container = document.getElementById("container");
const editor = monaco.editor.create(container, {
	value: "const text = 'hello';\n",
	language: "javascript",
});

// Scroll the page so the editor is 150px below the top of the window.
window.scrollTo(0, container.getBoundingClientRect().top + window.scrollY - 150);

// Open find, then hover its Match Case button.
editor.focus();
editor.trigger("repro", "actions.find", {});
Reproduction Steps
  1. Run the preview. The page scrolls to the editor and the find widget opens.
  2. Hover the find widget's Match Case button.
Actual (Problematic) Behavior

The tooltip doesn't appear: it's placed above the window, as far above its button as the page is scrolled (893px). On a page scrolled less, the tooltip shows, but too high by the scroll offset.

Expected Behavior

The tooltip opens just above (or below) its button wherever the page is scrolled.

Additional Context

HoverWidget.layout positions the tooltip relative to the window, from its target's getBoundingClientRect(), and HoverContextViewDelegate.getAnchor passes that position on unchanged. But ContextView lays out in page coordinates, so on a scrolled page the tooltip is placed as if its target were scrollY higher. Adding the window's scroll offset in getAnchor fixes it.

microsoft/vscode#283599 (in 0.57.0) fixed a similar mix-up in the context view's own position.

Dominant language
JavaScript
Stars
47k
Forks
4.2k
Avg merge
3d 13h
Merged PRs (30d)
13

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/monaco-editor

All issues in microsoft/monaco-editor

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.