Skip to content

Commit b5f2352

Browse files
committed
Force a recompute of the monaco editor height
Monaco allocates height on initialization, and sets this as a fixed height. By removing the height on a resize of the body, we force monaco to recompute the value and claim all newly available space of the flexbox layout. Note that we use a resize observer instead of a `$(window).resize`, as this will also trigger for other DOM changes and not just viewport changes.
1 parent 85854b2 commit b5f2352

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

webapp/public/js/domjudge.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,3 +1588,15 @@ function initDiffEditorTab(editorId, diffId, submissionId, models) {
15881588
}
15891589
diffEditor.onDidUpdateDiff(updateIcon);
15901590
}
1591+
1592+
// Force a recompute of the monaco editor height when the display size changes.
1593+
if ('ResizeObserver' in window) {
1594+
$(() => {
1595+
var monacoObserver = new ResizeObserver(() => {
1596+
document.querySelectorAll('.monaco-editor').forEach(e => {
1597+
e.style.height = "0";
1598+
});
1599+
});
1600+
monacoObserver.observe(document.body);
1601+
});
1602+
}

0 commit comments

Comments
 (0)