diff --git a/src/addons/mod/data/components/action/action.ts b/src/addons/mod/data/components/action/action.ts index 3d631249e..9105af4ab 100644 --- a/src/addons/mod/data/components/action/action.ts +++ b/src/addons/mod/data/components/action/action.ts @@ -200,7 +200,7 @@ export class AddonModDataActionComponent implements OnInit { }); } - await CoreDomUtils.openPopover({ + await CoreDomUtils.openPopoverWithoutResult({ component: AddonModDataActionsMenuComponent, componentProps: { items }, id: 'actionsmenu-popover', diff --git a/src/addons/mod/quiz/classes/auto-save.ts b/src/addons/mod/quiz/classes/auto-save.ts index bda15664a..bbe94a4c8 100644 --- a/src/addons/mod/quiz/classes/auto-save.ts +++ b/src/addons/mod/quiz/classes/auto-save.ts @@ -197,7 +197,7 @@ export class AddonModQuizAutoSave { }; this.popoverShown = true; - this.popover = await CoreDomUtils.openPopover({ + this.popover = await CoreDomUtils.openPopoverWithoutResult({ component: AddonModQuizConnectionErrorComponent, event: event, }); diff --git a/src/core/components/infinite-loading/core-infinite-loading.html b/src/core/components/infinite-loading/core-infinite-loading.html index 4ec1b60b2..8f92c736f 100644 --- a/src/core/components/infinite-loading/core-infinite-loading.html +++ b/src/core/components/infinite-loading/core-infinite-loading.html @@ -9,7 +9,8 @@ - + + diff --git a/src/core/components/infinite-loading/infinite-loading.ts b/src/core/components/infinite-loading/infinite-loading.ts index d1ed55b0d..80cdd626f 100644 --- a/src/core/components/infinite-loading/infinite-loading.ts +++ b/src/core/components/infinite-loading/infinite-loading.ts @@ -109,13 +109,11 @@ export class CoreInfiniteLoadingComponent implements OnChanges { /** * Complete loading. */ - complete(): void { - if (this.position == 'top') { - // Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't. - setTimeout(() => this.completeLoadMore(), 400); - } else { - this.completeLoadMore(); - } + async complete(): Promise { + // Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't. + await CoreUtils.wait(400); + + await this.completeLoadMore(); } /** diff --git a/src/core/features/course/components/module-completion/module-completion.ts b/src/core/features/course/components/module-completion/module-completion.ts index eaf008b04..dccb6d573 100644 --- a/src/core/features/course/components/module-completion/module-completion.ts +++ b/src/core/features/course/components/module-completion/module-completion.ts @@ -131,7 +131,7 @@ export class CoreCourseModuleCompletionComponent target = target.parentElement; } - CoreDomUtils.openPopover({ + CoreDomUtils.openPopoverWithoutResult({ component: CoreCourseModuleCompletionDetailsComponent, componentProps: { completion: this.completion, diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index 7ecded4ce..ccf004160 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -548,7 +548,7 @@ export class CoreDomUtilsProvider { el.addEventListener('click', async (ev: Event) => { const html = el.getAttribute('data-html'); - await CoreDomUtils.openPopover({ + await CoreDomUtils.openPopoverWithoutResult({ component: CoreBSTooltipComponent, componentProps: { content, @@ -1534,7 +1534,7 @@ export class CoreDomUtilsProvider { } /** - * Opens a popover. + * Opens a popover and waits for it to be dismissed to return the result. * * @param options Options. * @returns Promise resolved when the popover is dismissed or will be dismissed. @@ -1542,7 +1542,22 @@ export class CoreDomUtilsProvider { async openPopover(options: OpenPopoverOptions): Promise { const { waitForDismissCompleted, ...popoverOptions } = options; - const popover = await PopoverController.create(popoverOptions); + const popover = await this.openPopoverWithoutResult(popoverOptions); + + const result = waitForDismissCompleted ? await popover.onDidDismiss() : await popover.onWillDismiss(); + if (result?.data) { + return result?.data; + } + } + + /** + * Opens a popover. + * + * @param options Options. + * @returns Promise resolved when the popover is displayed. + */ + async openPopoverWithoutResult(options: Omit): Promise { + const popover = await PopoverController.create(options); const zoomLevel = await CoreConfig.get(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreConstants.CONFIG.defaultZoomLevel); await popover.present(); @@ -1559,10 +1574,7 @@ export class CoreDomUtilsProvider { } } - const result = waitForDismissCompleted ? await popover.onDidDismiss() : await popover.onWillDismiss(); - if (result?.data) { - return result?.data; - } + return popover; } /**