File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -84,13 +84,27 @@ export default class ReCAPTCHA extends React.Component {
8484
8585 componentWillUnmount ( ) {
8686 if ( this . _widgetId !== undefined ) {
87- while ( this . captcha . firstChild ) {
88- this . captcha . removeChild ( this . captcha . firstChild ) ;
89- }
87+ this . delayOfCaptchaIframeRemoving ( ) ;
9088 this . reset ( ) ;
9189 }
9290 }
9391
92+ delayOfCaptchaIframeRemoving ( ) {
93+ const temporaryNode = document . createElement ( "div" ) ;
94+ document . body . appendChild ( temporaryNode ) ;
95+ temporaryNode . style . display = "none" ;
96+
97+ // move of the recaptcha to a temporary node
98+ while ( this . captcha . firstChild ) {
99+ temporaryNode . appendChild ( this . captcha . firstChild ) ;
100+ }
101+
102+ // delete the temporary node after reset will be done
103+ setTimeout ( ( ) => {
104+ document . body . removeChild ( temporaryNode ) ;
105+ } , 5000 ) ;
106+ }
107+
94108 handleRecaptchaRef ( elem ) {
95109 this . captcha = elem ;
96110 }
You can’t perform that action at this time.
0 commit comments