recaptcha icon indicating copy to clipboard operation
recaptcha copied to clipboard

Doesn't work with Phoenix Live View

Open michaelforrest opened this issue 3 years ago • 4 comments

I'm struggling to get this to work with Phoenix Live View.

The live view submit handler is called before the recaptcha javascript can go through its sequence and update the form with a g-recaptcha-response field.

Here I'm inspecting the form generated with a phx_submit callback. The second handler is recaptcha's code, but the form has already been handled via live view by the time it gets to recaptchaCallback

I'm looking into live view's JS interoperability features but I'm not seeing a hook function that can be inserted before the submit event.

Actually it doesn't ever seem to be calling recaptchaCallback - I'm not sure how JS scope works if elements containing functions are replaced in the DOM. I see that the form value is being assigned to the window scope so maybe that's getting overwritten somehow as part of the live view render sequence.

I expect I'll be updating this thread with my findings as I go. Sorry not to have a test case for you.

michaelforrest avatar Jul 13 '21 17:07 michaelforrest