Skip to content

Commit 7c8415d

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 81410bd commit 7c8415d

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
@@ -1554,3 +1554,15 @@ function initDiffEditorTab(editorId, diffId, submissionId, models) {
15541554
}
15551555
diffEditor.onDidUpdateDiff(updateIcon);
15561556
}
1557+
1558+
// Force a recompute of the monaco editor height when the display size changes.
1559+
if ('ResizeObserver' in window) {
1560+
$(() => {
1561+
var monacoObserver = new ResizeObserver(() => {
1562+
document.querySelectorAll('.monaco-editor').forEach(e => {
1563+
e.style.height = "0";
1564+
});
1565+
});
1566+
monacoObserver.observe(document.body);
1567+
});
1568+
}

0 commit comments

Comments
 (0)