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

invisible_recaptcha_tags doesn't work with turbo_streams #423

Open
sovapatr opened this issue Jan 5, 2023 · 0 comments
Open

invisible_recaptcha_tags doesn't work with turbo_streams #423

sovapatr opened this issue Jan 5, 2023 · 0 comments

Comments

@sovapatr
Copy link

sovapatr commented Jan 5, 2023

When I submit a form in Rails 7 the respond_to format is always html and my turbo_stream.replace never runs.

It works if I make my own callback and change form.submit() to form.requestSubmit(). I'm unsure if all browsers support requestSubmit though. hotwired/turbo#775

<<-HTML
      <script>
        var invisibleRecaptchaSubmitForm = function () {
          var closestForm = function (ele) {
            var curEle = ele.parentNode;
            while (curEle.nodeName !== 'FORM' && curEle.nodeName !== 'BODY'){
              curEle = curEle.parentNode;
            }
            return curEle.nodeName === 'FORM' ? curEle : null
          };
          var el = document.querySelector(".g-recaptcha")
          if (!!el) {
            var form = closestForm(el);
            if (form) {
              form.requestSubmit();
            }
          }
        };
      </script>
HTML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant