Skip to content

Commit

Permalink
Merge pull request #3835 from dpalou/MOBILE-4362
Browse files Browse the repository at this point in the history
MOBILE-4362 quiz: Fix wrong renderization of ddwtos in some cases
  • Loading branch information
NoelDeMartin authored Oct 24, 2023
2 parents fc53f98 + 132c597 commit a32f0a7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/addons/qtype/ddwtos/classes/ddwtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,23 @@ export class AddonQtypeDdwtosQuestion {
return;
}

await CoreDom.waitToBeInDOM(groupItems[0]);

let maxWidth = 0;
let maxHeight = 0;
// Find max height and width.
groupItems.forEach((item) => {
item.innerHTML = CoreTextUtils.decodeHTML(item.innerHTML);
});

// Wait to render in order to calculate size.
await CoreUtils.nextTick();
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) => {
maxWidth = Math.max(maxWidth, Math.ceil(item.offsetWidth));
maxHeight = Math.max(maxHeight, Math.ceil(item.offsetHeight));
Expand Down

0 comments on commit a32f0a7

Please sign in to comment.