hotwired / turbo

The speed of a single-page web application without having to write any JavaScript
https://turbo.hotwired.dev
MIT License
6.64k stars 421 forks source link

Turbo Confirm is Ignored without Turbo Method #1296

Open DaAwesomeP opened 3 weeks ago

DaAwesomeP commented 3 weeks ago

Hello,

I have a vanilla rails new app with Rails 7.2.0. I have not touched any of the default Turbo configuration. I have confirmed with the web console that Turbo is enabled and the JS is included in the page.

If I create a link like:

<a class="nav-link" data-turbo-confirm="Are you sure?" href="/index2">Index 2</a>

then I do not see a conformation.

But if I do this:

<a class="nav-link" data-turbo-confirm="Are you sure?" data-turbo-method="get" href="/index2">Index 2</a>

then I see the confirmation prompt.

These links are in normal templates. I have not explicitly disabled Turbo anywhere.

From the docs (https://turbo.hotwired.dev/handbook/drive#requiring-confirmation-for-a-visit) it seems that shouldn't be necessary?

marcoroth commented 3 weeks ago

This should by solved by https://github.com/hotwired/turbo/pull/874

DaAwesomeP commented 3 weeks ago

Another possibly separate issue: If a link is to another domain/external, then adding data-turbo-method will cause Turbo to handle it, but it will ignore data-turbo-confirm.

tpaulshippy commented 2 weeks ago

Or https://github.com/hotwired/turbo/pull/1266 😁