File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
src/addons/qtype/ddwtos/classes Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff 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 ) ) ;
You can’t perform that action at this time.
0 commit comments