Skip to content

Commit 81a4277

Browse files
Fix multiple recaptchas
1 parent 374e10c commit 81a4277

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tutorcruncher-socket",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "TutorCruncher socket",
55
"author": "Samuel Colvin <[email protected]>",
66
"private": false,

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
socket(public_key, {
6767
element: '#socket4',
6868
router_mode: 'history',
69-
mode: 'enquiry-modal',
69+
mode: 'enquiry',
7070
api_root: api_root,
7171
})
7272
</script>

src/components/shared/EnquiryForm.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ class EnquiryForm extends Component {
6161

6262
render_grecaptcha () {
6363
const el = document.getElementById(this.grecaptcha_container_id)
64-
if (el && el.childElementCount === 0) {
65-
console.debug('rendering grecaptcha')
66-
window.grecaptcha.render(this.grecaptcha_container_id, {
67-
sitekey: this.props.config.grecaptcha_key,
68-
callback: response => this.set_enquiry_data('grecaptcha_response', response)
69-
})
64+
if (el) {
65+
if (el.childElementCount > 0) {
66+
console.debug(`${this.grecaptcha_container_id} already has a grecaptcha, not rendering`, el)
67+
} else {
68+
console.debug('rendering grecaptcha')
69+
window.grecaptcha.render(this.grecaptcha_container_id, {
70+
sitekey: this.props.config.grecaptcha_key,
71+
callback: response => this.set_enquiry_data('grecaptcha_response', response)
72+
})
73+
}
7074
} else {
71-
console.warn('not rendering grecaptcha', el)
75+
console.warn(`${this.grecaptcha_container_id} doesn't exist, not rendering`, el)
7276
}
7377
}
7478

0 commit comments

Comments
 (0)