From 5ea60ecccd56d9c97e440ef7ae2a1f98cafb17b3 Mon Sep 17 00:00:00 2001 From: Iain Beeston Date: Thu, 21 Nov 2024 17:43:32 +0000 Subject: [PATCH] Fix Turbo.config.forms.confirm deprecation message Turbo 8 deprecated `Turbo.setConfirmMethod()` and instead moved it to `Turbo.config.forms.confirm` instead (see https://github.com/hotwired/turbo/pull/1216). Because of that, avo is throwing deprecation messages in the javascript console: Please replace `Turbo.setConfirmMethod(confirmMethod)` with `Turbo.config.forms.confirm = confirmMethod`. The top-level function is deprecated and will be removed in a future version of Turbo. I've updated the code to use the new config object instead, which should resolve the deprecation warning. --- app/javascript/js/custom-confirm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/js/custom-confirm.js b/app/javascript/js/custom-confirm.js index 9a7887fd29..5934ee4007 100644 --- a/app/javascript/js/custom-confirm.js +++ b/app/javascript/js/custom-confirm.js @@ -1,6 +1,6 @@ import { Turbo } from '@hotwired/turbo-rails' -Turbo.setConfirmMethod((message) => { +Turbo.config.forms.confirm = (message) => { const dialog = document.getElementById('turbo-confirm') dialog.querySelector('p').textContent = message dialog.showModal() @@ -16,4 +16,4 @@ Turbo.setConfirmMethod((message) => { resolve(dialog.returnValue === 'confirm') }, { once: true }) }) -}) +}