nuxt-modules / turnstile

πŸ”₯ Cloudflare Turnstile integration for Nuxt

Home Page:https://cloudflare.com/products/turnstile

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Callback loop with `NuxtTurnstile`

huang-julien opened this issue Β· comments

πŸ› The bug

When changing the page, the turnstile box isn't properly removed and causing and infinite loop.

to reproduce it on the reproduction,

  • go to the form page
  • load the turnstile iframes
  • wait for it
  • navigate back to the homepage
  • open your console
  • check your logs

πŸ› οΈ To reproduce

https://stackblitz.com/edit/github-cuqope?file=pages%2Findex.vue,pages%2Fform.vue

🌈 Expected behaviour

we shouldn't have any warning log

ℹ️ Additional context

I can take it, already fixed on my project :)

I noticed that too, recently. If you want feel free to submit a PR! ❀️

sure !

commented

Waiting for fixing.

Oops for those interested here's the workaround atm,
within onBeforeUnmount of the compoennt wrapper NuxtTurnstile
window.turnstile.remove(str) where str is the wrapper selector + div
ex:

onBeforeUnmount(() => {
  window.turnstile.remove('#turnstile-wrapper div')
})

Turnstile remove function either can receive the id of the widget or if it's a selector, look for the iframe of the widget within the selector