Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using data-tubo-method="delete" and data-turbo-confirm in links (possible memory leak( #878

Open
nsilva-ta opened this issue Feb 22, 2023 · 2 comments

Comments

@nsilva-ta
Copy link

I'm trying the examples in documentation for Requiring Confirmation for a Visit.

<a href="/articles" data-turbo-confirm="Do you want to leave this page?">Back to articles</a>
<a href="/articles/54" data-turbo-method="delete" data-turbo-confirm="Are you sure you want to delete the article?">Delete the article</a>

The data-turbo-confirm is ignored in the first link.
The second links keeps creating related forms if the the confirmation message is canceled each time the link is clicked.

image

@seanpdoyle
Copy link
Contributor

Thank you for opening this issue!

Self-removal after a dismissed confirmation is the latest in a long list of quirks that Turbo's handling of <a>-as-<form> elements needs to account for.

In the short term, is it possible to replace the <a data-turbo-method="delete"> with a <form>?

@nsilva-ta
Copy link
Author

Yes, it's possible.

I see that Turbo creates the form and transfers attributes from the link to the form to have the form process data-turbo-confirm with it's submission process exiting if confirmMethod is false. And more quirks arrive as we need more data from the link element to make a cool confirmation dialog.
What about having the confirmMethod avaliable in FormLinkClickObserver and calling it before form creation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants