import "@hotwired/turbo-rails" Turbo.config.drive.progressBarDelay = 300 Turbo.config.forms.confirm = (title) => { const dialog = document.getElementById("main-dialog") const dialogTitle = dialog.querySelector('[data-modal=title]') const previousTitleContent = dialogTitle.textContent dialogTitle.textContent = title dialog.showModal() return new Promise((resolve, _) => { dialog.addEventListener( "close", () => { dialogTitle.textContent = previousTitleContent resolve(dialog.returnValue == "confirm") }, { once: true }, ); }); } import "controllers"