MOBILE-4362 quiz: Fix wrong renderization of ddwtos in some cases

main
Dani Palou 2023-10-23 16:32:54 +02:00
parent f8fe8aee36
commit 132c597e81
1 changed files with 13 additions and 7 deletions

View File

@ -480,17 +480,23 @@ export class AddonQtypeDdwtosQuestion {
return; return;
} }
await CoreDom.waitToBeInDOM(groupItems[0]);
let maxWidth = 0;
let maxHeight = 0;
// Find max height and width.
groupItems.forEach((item) => { groupItems.forEach((item) => {
item.innerHTML = CoreTextUtils.decodeHTML(item.innerHTML); item.innerHTML = CoreTextUtils.decodeHTML(item.innerHTML);
}); });
// Wait to render in order to calculate size.
await CoreUtils.nextTick();
// Wait to render in order to calculate size.
if (groupItems[0].parentElement) {
// Wait for parent to be visible. We cannot wait for group items because they have visibility hidden.
await CoreDom.waitToBeVisible(groupItems[0].parentElement);
} else {
// Group items should always have a parent, add a fallback just in case.
await CoreDom.waitToBeInDOM(groupItems[0]);
await CoreUtils.nextTicks(5);
}
// Find max height and width.
let maxWidth = 0;
let maxHeight = 0;
groupItems.forEach((item) => { groupItems.forEach((item) => {
maxWidth = Math.max(maxWidth, Math.ceil(item.offsetWidth)); maxWidth = Math.max(maxWidth, Math.ceil(item.offsetWidth));
maxHeight = Math.max(maxHeight, Math.ceil(item.offsetHeight)); maxHeight = Math.max(maxHeight, Math.ceil(item.offsetHeight));