Fallback to default height if editor offset cannot be determined

Fixes CODEOCEAN-B6, Fixes CODEOCEAN-E1, Fixes CODEOCEAN-BZ
This commit is contained in:
Sebastian Serth
2022-10-06 00:24:23 +02:00
parent df384ebf0d
commit 9e1f2da02e

View File

@ -231,9 +231,14 @@ var CodeOceanEditor = {
},
calculateEditorHeight: function (element, considerStatusbar) {
let bottom = considerStatusbar ? ($('#statusbar').height() || 0) : 0;
const jqueryElement = $(element);
if (jqueryElement.length === 0) {
return 0;
}
const bottom = considerStatusbar ? ($('#statusbar').height() || 0) : 0;
// calculate needed size: window height - position of top of ACE editor - height of autosave label below editor - 5 for bar margins
return window.innerHeight - $(element).offset().top - bottom - 5;
return window.innerHeight - jqueryElement.offset().top - bottom - 5;
},
resizeParentOfAceEditor: function (element) {