[Bug] Find Widget Tooltip Issues
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, typescript
- Domain
- accessibility, frontend
Research direction
Start with the Find widget and tooltip behavior using the supplied Monaco Editor Playground reproduction, including the minimap-disabled and padded-container cases. Trace the editor container anchoring, widget right offset, tooltip wrapping, and the reported aria-hidden warning. Done means the tooltips remain correctly anchored and usable across these layouts without the focus warning.
Written by the indexing model from the issue text.
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
const value = /* set from `myEditor.getModel()`: */ `function hello() {
alert('Hello world!');
}`;
// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
value,
language: "javascript",
automaticLayout: true,
minimap: { enabled: false },
});
Reproduction Steps
There are a few closely related issues involved. You have to manipulate the playground editor's iframe content a bit to match the type of layout where this issue occurs. There's nothing special about the referenced playground other than disabling the minimap.
- The minimap needs to be disabled, as done in the provided example.
- Open the Find widget (Ctrl+F) and hover over the options to see the tooltips. They display below the widget, because there isn't room for them to display above the widget (within the iframe). No issue so far, and even without the minimap, the tooltips all have space to display on one line (except not actually - you can see that the two for the options on the far right aren't centered and have to be moved left to fit on one line).
- However, the editor can't always be expected to extend to the edges of its page. So, simulate an editor that doesn't extend to the edges by using the browser dev tools to inspect the iframe's body tag and give it a style of
padding: 50px;. For good measure, give the editor container element (the div with id="container") a border by adding the styleborder: 1px solid gray;. Now hover over the Find widget options to view the tooltips again. - Problem 1: The tooltips no longer show below the widget, because the top padding gives them enough space to display above it. However, they are anchored to the top edge of the page rather than to the editor, because they are absolutely positioned and the editor container does not have
position: relativeapplied. - Problem 1 Workaround: Manually apply a style of
position: relativeto the editor container element. This can be done with the browser dev tools for testing purposes, but developers would need to manually style their containers this way when implementing the editor. So, the editor probably ought to be updated to automatically apply this style to its container element. - Now observe the tooltips. They display above the editor with proper anchoring. That's great. But remember those offset tooltips for the options on the right end of the Find widget?
- Problem 2: When not up against the page edge, tooltips wrap instead of get offset. This isn't too bad when displayed below, but when tooltips are displayed above the widget, that becomes an issue, because their position assumes a single line, and the wrapped line results in the tooltip overlapping the option itself, causing the tooltip to endlessly blink in and out while also blocking attempts to actually click the option.
- Problem 2 Workaround: Manually apply a style to the Find widget to move it further away from the right edge of the editor. An offset of 33px in total (with no minimap) seems to be the magic number for the playground in my browser, but this is highly dependent on factors like the tooltip font, and I can't guarantee that it would always suffice. The editor really ought to handle the widget's positioning robustly all on its own, perhaps by using getBoundingClientRect() to account for rendered sizes, and tooltip positioning above an anchor would ideally account for if it's wrapped to multiple lines. Also, having tooltips get offset rather than wrap even when not up against the page edge might be a good idea.
- Note that the editor's vertical scrollbar width can also be configured with the scrollbar: verticalScrollbarSize property. It seems to default to 14 (pixels), and the Find widget's
rightstyle value seems to always be set to double the scrollbar size (28px by default) plus the minimap width if enabled (90px, totaling to 118px by default). I don't know what the reasoning may have been for it to be double the scrollbar size, but the Find widget's right offset probably ought to be one times the verticalScrollbarSize, not two, plus some constant offset, with the minimap size added (90px or 0), and should enforce a minimum offset that always ensures enough room for the tooltips to display.
Actual (Problematic) Behavior
With no minimap, notice that tooltips for the rightmost Find widget options are offset to the left, as the widget isn't far enough from the right edge of the editor container to allow them to be both single-line and centered:
Tooltips are anchored to the page's top edge rather than the editor because the editor container doesn't have position: relative:
With the option tooltip anchored above the widget, if it wraps to a second line, it blocks the option itself, and often blinks in and out repeatedly:
A verticalScrollbarSize of 1 causes the Find widget to be only 2px from the container's edge (when minimap is disabled):
A verticalScrollbarSize of 50 causes the Find widget to (unnecessarily) be 100px from the container's edge (when minimap is disabled):
Expected Behavior
The editor container has position: relative applied, and the Find widget has a sufficient right offset applied for the tooltips to display:
Additional Context
See https://github.com/microsoft/monaco-editor/issues/5137 for an initial report of some of these issues. Hopefully enough detail is provided now to be able to implement the necessary fixes.
By the way, every time the Find widget is opened, it produces this console warning about focus being inside an element with aria-hidden. It would be great if that could be resolved as well.
Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden. Element with focus: <textarea.input empty> Ancestor with aria-hidden: <div.editor-widget find-widget>
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
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.
More from microsoft/monaco-editor
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
microsoft/monaco-editor#5314 · 2 comments · 4 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
microsoft/monaco-editor#5248 · 8 comments · 57 reactions ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
microsoft/monaco-editor#5193 ·
-
[Bug] colorizeElement method doesn't color the whole text if domNode has more than one #text child Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/monaco-editor#4571 ·
-
bug help wanted integration
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microsoft/monaco-editor#4045 · 8 comments · 11 reactions ·
All issues in microsoft/monaco-editor
Similar issues
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100