Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google reCaptcha verification popup not displaying properly in Mat Dialog

I added google reCaptcha in angular material dialog form. But when reCaptcha opens verification popup, it display above the form like in pic.

enter image description here

I also found that whenever mat dialog opens it adds the negative margins to the html tag. And if I remove the margin the captcha verification popup goes into right place but then mat dialog not display properly. I am confused how to make both popup in right place.

like image 322
Suhel Avatar asked Feb 27 '19 05:02

Suhel


People also ask

How do I fix reCAPTCHA verification?

Help for reCAPTCHA users There are a few steps you can take to improve your experience: Make sure your browser is fully updated (see minimum browser requirements) Check that JavaScript is enabled in your browser. Try disabling plugins that might conflict with reCAPTCHA.

Why reCAPTCHA is not showing sometimes?

If reCAPTCHA is not working in your browser, then this issue may arise due to several reasons that include: You are using an older version of your web browser. VPN or proxy service is interrupting with reCAPTCHA. The browser is infected with malware like a browser hijacker, trojan, adware tool, etc.

Which is better reCAPTCHA v2 or v3?

What is the difference between reCAPTCHA v2 and v3? ReCAPTCHA v2 requires the user to click the “I'm not a robot” checkbox and can serve the user an image recognition challenge. ReCAPTCHA v3 runs in the background and generates a score based on a user's behavior. The higher the score, the more likely the user is human.

What is Google reCAPTCHA verification failed Please try again later?

It looks like you may have the W3 Total Cache plugin activated on your site. In many cases, caching and minification can result in the reCAPTCHA script being loaded incorrectly.


1 Answers

I solved problem(kind of hack) at that time only but waiting for proper solution.

Peoples asking why I am adding captcha in popup, so guys its product requirement so can't change.

So what I did, I check for the captcha challenge popup when it appears I change the margins set by the material dialog in html tag like below.

checkForChallengePopup() {
    const html: HTMLElement = this.document.getElementsByTagName('html')[0];
    this.challengePopup = this.document.querySelector(`[title='recaptcha challenge']`);
    if (this.challengePopup) {
      this.challengePopup.parentElement.style.top = html.style.top.replace('-', '');
    } else {
      setTimeout(() => {
        this.checkForChallengePopup();
      }, 3000);
    }
  }

And yeah it keep on checking for the challenge pop-up till main dialog is not closed so kind a dirty but did the trick.

like image 125
Suhel Avatar answered Sep 24 '22 02:09

Suhel