[A11y] Widget: pass doc title in overlay to iframe.title (#5210)

This commit is contained in:
Richard Schreiber
2025-06-10 20:41:51 +02:00
committed by GitHub
parent cced9cd768
commit 362ac8de6f
2 changed files with 19 additions and 0 deletions

View File

@@ -7,4 +7,12 @@ var inIframe = function () {
};
if (inIframe()) {
document.documentElement.classList.add('in-iframe');
try {
window.parent.postMessage({
type: "pretix:widget:title",
title: document.title,
}, "*");
} catch (e) {
console.error("Could not post message to parent.", e);
}
}

View File

@@ -939,7 +939,18 @@ Vue.component('pretix-overlay', {
}
},
},
mounted () {
window.addEventListener('message', this.onMessage, false);
},
unmounted () {
window.removeEventListener('message', this.onMessage, false);
},
methods: {
onMessage: function(e) {
if (e.data.type && e.data.type == "pretix:widget:title") {
this.$el.querySelector("iframe").title = e.data.title;
}
},
lightboxClose: function () {
this.$root.lightbox = null;
},