Skip to content

Commit 1a5e48b

Browse files
authored
fix(editor): create portal for monaco overflow widgets (#67)
1 parent 48b03b1 commit 1a5e48b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/app/src/components/AppLayout.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ function onLeave(el: Element, done: () => void) {
4949
>
5050
<div
5151
v-if="open"
52-
class="fixed top-0 bottom-0 left-0 overflow-y-auto border-r border-default flex flex-col max-w-full bg-default"
52+
class="fixed top-0 bottom-0 left-0 border-r border-default flex flex-col max-w-full bg-default"
5353
:style="sidebarStyle"
5454
>
55+
<!-- This is needed for the Monaco editor to be able to position the portal correctly -->
56+
<div class="monaco-editor">
57+
<div id="monaco-portal" />
58+
</div>
59+
5560
<AppHeader />
5661

5762
<div class="flex-1 overflow-y-auto relative">

src/app/src/composables/useMonaco.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,19 @@ export function useMonaco(target: Ref<HTMLElement | undefined>, options: UseMona
3535

3636
const colorMode = unref(options.colorMode) || 'dark'
3737

38+
const monacoPortal = (el.getRootNode() as Document)?.getElementById('monaco-portal') || undefined
39+
if (monacoPortal) {
40+
monacoPortal.style.position = 'absolute'
41+
monacoPortal.style.top = el.getClientRects()[0].top + 'px'
42+
}
43+
3844
// Create editor instance (use the custom createEditor wrapper from setupMonaco)
3945
editor.value = monaco.createEditor(el, {
4046
theme: getTheme(colorMode),
4147
lineNumbers: 'off',
4248
readOnly: options.readOnly ?? false,
4349
wordWrap: 'on',
50+
overflowWidgetsDomNode: monacoPortal,
4451
scrollbar: options.readOnly
4552
? {
4653
vertical: 'hidden',

0 commit comments

Comments
 (0)