import { Controller } from "@hotwired/stimulus" // Connects to data-controller="turbo-frame-timeout" export default class extends Controller { static values = { timeout: { type: Number, default: 10000 } } connect() { this.timeoutId = setTimeout(() => { this.handleTimeout() }, this.timeoutValue) // Listen for successful frame loads to clear timeout this.element.addEventListener("turbo:frame-load", this.clearTimeout.bind(this)) } disconnect() { this.clearTimeout() } clearTimeout() { if (this.timeoutId) { clearTimeout(this.timeoutId) this.timeoutId = null } } handleTimeout() { // Replace loading content with error state this.element.innerHTML = `
Timeout