Skip to content

Commit

Permalink
Fix Turbo.config.forms.confirm deprecation message
Browse files Browse the repository at this point in the history
Turbo 8 deprecated `Turbo.setConfirmMethod()` and instead moved it to `Turbo.config.forms.confirm` instead (see hotwired/turbo#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.
  • Loading branch information
iainbeeston authored Nov 21, 2024
1 parent c3134f5 commit 5ea60ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/javascript/js/custom-confirm.js
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -16,4 +16,4 @@ Turbo.setConfirmMethod((message) => {
resolve(dialog.returnValue === 'confirm')
}, { once: true })
})
})
}

0 comments on commit 5ea60ec

Please sign in to comment.