Skip to content

Commit b867ad1

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 45b0817 commit b867ad1

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
@@ -1290,3 +1290,15 @@ function initScoreboardSubmissions() {
12901290
});
12911291
});
12921292
}
1293+
1294+
// Force a recompute of the monaco editor height when the display size changes.
1295+
if ('ResizeObserver' in window) {
1296+
$(() => {
1297+
var monacoObserver = new ResizeObserver(() => {
1298+
document.querySelectorAll('.monaco-editor').forEach(e => {
1299+
e.style.height = "0";
1300+
});
1301+
});
1302+
monacoObserver.observe(document.body);
1303+
});
1304+
}

0 commit comments

Comments
 (0)