You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As recommended on StackOverflow, I am displaying an IContentWidget over an IViewZone so that I can handle input events in my overlay. It seems that if the content widget is larger than the viewport, it does not render correctly. Note this is not an issue if I use the same domNode for the IViewZone, but then I lose the ability to receive input events.
The code sample below creates an editor with 2000 lines and inserts an IViewZone/IContentWidget combination that is 100 lines long, which should be larger than the viewport unless you have a very tall browser window...
As you can see, when the top of the widget is in view, everything is fine, but if you try to scroll to the middle, it seemingly disappears.
monaco-editor version: 0.19.3 Browser: Google Chrome OS: macOS Playground code that reproduces the issue:
// Code sample for Monaco Playground that demonstrates// that when a large content widget is scrolled, it disappears.constlines=[];for(leti=0;i<2000;i++){lines.push(`console.log(${i});\n`);}consteditor=monaco.editor.create(document.getElementById("container"),{value: lines.join(''),language: "javascript"});constlineNumber=7;editor.changeViewZones(accessor=>{constdomNode=document.createElement('div');constzone={afterLineNumber: lineNumber,heightInLines: 100,
domNode,onComputedHeight: height=>addContentWidgetWithHeight(height),};accessor.addZone(zone);});functionaddContentWidgetWithHeight(height){letdomNode=null;constcontentWidget={getId: function(){return'my.content.widget';},getDomNode: function(){if(!domNode){domNode=document.createElement('div');domNode.innerHTML='My content widget';domNode.style.background='grey';constwidth=editor.getDomNode().clientWidth;domNode.style.width=`${width}px`;domNode.style.height=`${height}px`;}returndomNode;},getPosition: function(){return{position: {
lineNumber,column: 1},preference: [monaco.editor.ContentWidgetPositionPreference.BELOW]};}};editor.addContentWidget(contentWidget);}
The text was updated successfully, but these errors were encountered:
In this case, IMHO it would be better to pair a view zone with an overlay widget. That is what we do for the embedded experience of find all references and for the error navigation at F8.
alexdima
added
info-needed
Issue requires more information from poster
and removed
bug
Issue identified by VS Code Team member as probable bug
labels
Jan 28, 2020
As recommended on StackOverflow, I am displaying an
IContentWidget
over anIViewZone
so that I can handle input events in my overlay. It seems that if the content widget is larger than the viewport, it does not render correctly. Note this is not an issue if I use the samedomNode
for theIViewZone
, but then I lose the ability to receive input events.The code sample below creates an editor with 2000 lines and inserts an
IViewZone
/IContentWidget
combination that is 100 lines long, which should be larger than the viewport unless you have a very tall browser window...As you can see, when the top of the widget is in view, everything is fine, but if you try to scroll to the middle, it seemingly disappears.
monaco-editor version: 0.19.3
Browser: Google Chrome
OS: macOS
Playground code that reproduces the issue:
The text was updated successfully, but these errors were encountered: