From b241adb7d0502db43f60a979b82a4ffbb119367a Mon Sep 17 00:00:00 2001 From: pajowu Date: Fri, 14 Aug 2026 12:34:55 +0200 Subject: [PATCH] Fix safari blocking widget opening error url in new tab (Z#23243124) (#6477) * Fix safari blocking widget opening error url in new tab (Z#23243124) * Fix autofocus in vue3 widget autofocus no longer works as the elements are added dynamically * fix eslint * rename v-focus to v-autofocus --------- Co-authored-by: Richard Schreiber --- .../static/pretixpresale/js/widget/widget.js | 25 ++++++++-------- .../widget/src/components/Overlay.vue | 30 +++++++++++-------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index 22c44c8ed..232c9ecd1 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -262,7 +262,7 @@ Vue.component('availbox', { }, mounted: function() { if (!this.$root.cart_exists && this.$root.itemnum === 1 && (!this.$root.categories[0].items[0].has_variations || this.$root.categories[0].items[0].variations.length < 2) && !this.$root.has_seating_plan ? 1 : 0) { - this.$refs.quantity.value = 1; + this.$refs.quantity.value = 1; if (this.order_max === 1) { this.$refs.quantity.checked = true; } @@ -310,7 +310,7 @@ Vue.component('availbox', { return this.avail[0] < 100 && this.$root.waiting_list_enabled && this.item.allow_waitinglist; }, waiting_list_url: function () { - var u = this.$root.target_url + 'w/' + widget_id + '/waitinglist/?locale=' + lang + '&item=' + this.item.id + var u = this.$root.target_url + 'w/' + widget_id + '/waitinglist/?locale=' + lang + '&item=' + this.item.id if (this.item.has_variations) { u += '&var=' + this.variation.id } @@ -863,7 +863,7 @@ var shared_alert_fragment = ( '' + '
' + '

{{ $root.error_message }}

' - + '

' + + '

' + '

' + '
' + '' @@ -952,7 +952,7 @@ Vue.component('pretix-overlay', { cancelBlockedClasses: function () { return { 'pretix-widget-visibility-hidden': !this.cancelBlocked, - } + } }, }, mounted () { @@ -974,19 +974,18 @@ Vue.component('pretix-overlay', { this.$root.lightbox.loading = false; }, errorClose: function (e) { - var dialog = e.target; - if (dialog.returnValue == "continue" && this.$root.error_url_after) { - if (this.$root.error_url_after_new_tab) { - window.open(this.$root.error_url_after); - } else if (this.$root.overlay) { - this.$root.overlay.frame_src = this.$root.error_url_after; - this.$root.frame_loading = true; - } - } this.$root.error_message = null; this.$root.error_url_after = null; this.$root.error_url_after_new_tab = false; }, + errorContinue: function () { + if (this.$root.error_url_after_new_tab) { + window.open(this.$root.error_url_after); + } else if (this.$root.overlay) { + this.$root.overlay.frame_src = this.$root.error_url_after; + this.$root.frame_loading = true; + } + }, close: function (e) { if (this.$root.frame_loading) { // Chrome does not allow blocking dialog.cancel event more than once diff --git a/src/pretix/static/pretixpresale/widget/src/components/Overlay.vue b/src/pretix/static/pretixpresale/widget/src/components/Overlay.vue index 4f139fce7..4defa3473 100644 --- a/src/pretix/static/pretixpresale/widget/src/components/Overlay.vue +++ b/src/pretix/static/pretixpresale/widget/src/components/Overlay.vue @@ -54,16 +54,16 @@ function lightboxLoaded () { } } -function errorClose (e: Event) { - const dialog = e.target as HTMLDialogElement - if (dialog.returnValue === 'continue' && store.overlay.errorUrlAfter) { - if (store.overlay.errorUrlAfterNewTab) { - window.open(store.overlay.errorUrlAfter) - } else { - store.overlay.frameSrc = store.overlay.errorUrlAfter - store.overlay.frameLoading = true - } +function errorContinue () { + if (store.overlay.errorUrlAfterNewTab) { + window.open(store.overlay.errorUrlAfter) + } else { + store.overlay.frameSrc = store.overlay.errorUrlAfter + store.overlay.frameLoading = true } +} + +function errorClose () { store.overlay.errorMessage = null store.overlay.errorUrlAfter = null store.overlay.errorUrlAfterNewTab = false @@ -168,6 +168,10 @@ onMounted(() => { onUnmounted(() => { window.removeEventListener('message', onMessage, false) }) + +const vAutofocus = { + mounted: (el) => el.focus() +}