fix: scroll parent page to top on iframe load

This commit is contained in:
Björn Fromme
2025-01-26 20:59:47 +01:00
parent 427539481f
commit dd60ce9688
2 changed files with 15 additions and 2 deletions
+13
View File
@@ -0,0 +1,13 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
connect() {
if ('parentIframe' in window) {
window.iFrameResizer = {
onReady: function () {
window.parentIFrame.scrollTo(0, 0)
}
}
}
}
}
+2 -2
View File
@@ -7,7 +7,7 @@
{% set messages = form.vars.errors|map(error => error.message) %}
{% include '_partials/_alert.html.twig' with { 'level': 'error', 'title': 'Die Buchung konnte nicht aktualisiert werden', 'messages': messages } %}
{% endif %}
<div class="flex flex-col space-y-8 pb-4" {{ stimulus_controller('booking', { 'availabilities': availabilities.items }) }}>
<div class="flex flex-col space-y-8 pb-4" {{ stimulus_controller('booking', { 'availabilities': availabilities.items }) }} {{ stimulus_controller('iframe') }}>
<div class="p-8 border border-gray-300 rounded-md"
{{ stimulus_controller('toggle', { 'open': true }, { 'closed': 'hidden' }) }}>
<div role="button" class="flex items-center justify-between" {{ stimulus_action('toggle', 'toggle', 'click') }}>
@@ -210,7 +210,7 @@
zurück
</a>
<button type="submit"
class="button bg-button bg-button--secondary" {{ stimulus_action('loading', 'toggle') }}>
class="button bg-button bg-button--secondary" {{ stimulus_action('loading', 'toggle', null, { 'scroll': true }) }}>
Aktualisieren
</button>
</div>