Skip to content

Commit d3b8734

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 e55bb5e commit d3b8734

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
@@ -1561,3 +1561,15 @@ function initDiffEditorTab(editorId, diffId, submissionId, models) {
15611561
}
15621562
diffEditor.onDidUpdateDiff(updateIcon);
15631563
}
1564+
1565+
// Force a recompute of the monaco editor height when the display size changes.
1566+
if ('ResizeObserver' in window) {
1567+
$(() => {
1568+
var monacoObserver = new ResizeObserver(() => {
1569+
document.querySelectorAll('.monaco-editor').forEach(e => {
1570+
e.style.height = "0";
1571+
});
1572+
});
1573+
monacoObserver.observe(document.body);
1574+
});
1575+
}

0 commit comments

Comments
 (0)