From b75f8bf893c5bb043ef8ea4fa1dd785883c0fc27 Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Tue, 10 Jun 2025 20:35:11 +0200 Subject: [PATCH] Widget: fix loading spinner not showing on API-request (#5228) * Widget: fix loading spinner not showing while API-request * remove not needed showModal as it is handled be frame_loading-watcher * add double check if dialog is open before closing it --- src/pretix/static/pretixpresale/js/widget/widget.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index 079e1ddbd9..ce474d03a4 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -2182,11 +2182,22 @@ var create_overlay = function (app) { // show loading spinner only when previously no frame_src was set if (newValue && !oldValue) { this.frame_loading = true; - this.$el?.querySelector('dialog.pretix-widget-frame-holder').showModal(); } // to close and unload the iframe, frame_src can be empty -> make it valid HTML with about:blank this.$el.querySelector("iframe").src = newValue || "about:blank"; }, + frame_loading: function (newValue) { + var dialog = this.$el?.querySelector('dialog.pretix-widget-frame-holder'); + if (newValue) { + if (!dialog.open) { + dialog.showModal(); + } + } else { + if (!this.frame_src && dialog.open) {// finished loading, but no iframe to display => close + dialog.close(); + } + } + }, } }); app.$root.overlay = framechild;