import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = ["dialog"] confirm(event) { // The second pass — after the player confirmed — falls through to Turbo. if (this.confirmed) return event.preventDefault() this.pendingForm = event.target this.dialogTarget.showModal() } ok() { this.dialogTarget.close() // requestSubmit(), not submit(): the native call skips the submit event, so // Turbo would miss it and navigate the whole page out of the game frame. this.confirmed = true this.pendingForm?.requestSubmit() } cancel() { this.dialogTarget.close() this.pendingForm = null } backdropClick(event) { if (event.target === this.dialogTarget) this.cancel() } }