-
Notifications
You must be signed in to change notification settings - Fork 126
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
Reactive forms refresh #201
Comments
Hi @Jordan-Hall, and thank you for reaching out! When you say "refresh the page" -- what exactly do you mean, can you elaborate? How are you getting the "valid token" from the component? |
So i completed the form, captcha. I then refresh the website. The captcha apparently still contains a value but not ticked |
What makes you think that captcha still contains a value? reCAPTCHA value is only ever stored in memory, and is not preserved upon page reloads |
@DethAriel because when i debugged the code it still had a value in the reactive form |
@Jordan-Hall can you come up with a repro code sample and step-by-step instuctions? This behavior certainly sounds unexpected, but unfortunately I can't reproduce myself. |
I am seeing the same issue with reactive form. I think what @Jordan-Hall wanted to say is not "reload" the page but destroy the recaptcha component. My workflow:
|
up |
a workaround for this issue (at least mine, @Jordan-Hall if what i describe is not your issue, pls tell me and I will open up another issue) is to not use formValueAccessor and instead use the resolved event to manually patch the form. That way I can at least reset the formControl to be aligned with the recaptcha component |
Thank you very much for the reproduction scenario @mokipedia! I can now reliably reproduce the behavior. At this point I'm still on the fence whether to treat this as a bug, and if so - whether to fix it or not. The value provided as reCAPTCHA responses are supposed to be single-use only, and after grabbing it and passing it to the server, the reasonable expectation is that developers will reset the If you (or anyone else) are looking for a way to avoid this unfortunate situation, my recommendation would be to manually reset public onFromSubmit() {
this.tryLoginUser(this.formGroup.value)
.subscribe(() => {
// if success, probably navigate away
this.navigate();
}, (error) => {
// if error, and reCAPTCHA challenge needs to be presented again, reset its value
this.formGroup.setValue({ captcha: null });
});
} |
@DethAriel have you tried that? I tried to patch or set value, in that case your formvalueaccessor screamed at me that this is not allowed. (Haven't tried since writing my workaround, so maybe it changed?) |
@mokipedia yes, this does result in a console error from the value accessor (which is another avenue for a fix), however this error doesn't really affect the app in any detrimental way |
@DethAriel I would agree not fixing this might be the way to go as long as you allow a reset without error (e.g. with control value accessor) However doing a reset like you suggest actually breaks logic in a form I am using it, hence the workaround. Not sure what exactly happens but the form is unusable afterwards. |
@mokipedia understood, thanks for working through this issue with me. I think I have an idea of how to fix this now, so I'll be working on a code update. What |
7.0.1 at the time of first noticing the error due to a code refactor on our side. |
The error that is generated when one is performing
While there is a lib-specific workaround I can implement, I'd rather not go that route. Especially considering that a fix for this issue that I'll back-port to 7.x.x branch will no longer require you to clear the form value manually. |
…ction This is a back-port of 8.x.x fix for #201
This has now been fixed and released in |
Summary
I'm submitting a:
When using the component inside reactive forms I've notice a bug. When you refresh the page the component has a valid token but, not showing it it ticked
The text was updated successfully, but these errors were encountered: