Skip to content

Commit 132c597

Browse files
committed
MOBILE-4362 quiz: Fix wrong renderization of ddwtos in some cases
1 parent f8fe8ae commit 132c597

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/addons/qtype/ddwtos/classes/ddwtos.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,17 +480,23 @@ export class AddonQtypeDdwtosQuestion {
480480
return;
481481
}
482482

483-
await CoreDom.waitToBeInDOM(groupItems[0]);
484-
485-
let maxWidth = 0;
486-
let maxHeight = 0;
487-
// Find max height and width.
488483
groupItems.forEach((item) => {
489484
item.innerHTML = CoreTextUtils.decodeHTML(item.innerHTML);
490485
});
486+
491487
// Wait to render in order to calculate size.
492-
await CoreUtils.nextTick();
488+
if (groupItems[0].parentElement) {
489+
// Wait for parent to be visible. We cannot wait for group items because they have visibility hidden.
490+
await CoreDom.waitToBeVisible(groupItems[0].parentElement);
491+
} else {
492+
// Group items should always have a parent, add a fallback just in case.
493+
await CoreDom.waitToBeInDOM(groupItems[0]);
494+
await CoreUtils.nextTicks(5);
495+
}
493496

497+
// Find max height and width.
498+
let maxWidth = 0;
499+
let maxHeight = 0;
494500
groupItems.forEach((item) => {
495501
maxWidth = Math.max(maxWidth, Math.ceil(item.offsetWidth));
496502
maxHeight = Math.max(maxHeight, Math.ceil(item.offsetHeight));

0 commit comments

Comments
 (0)