File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import { Icon } from 'astro-icon/components';
37
37
<fieldset >
38
38
<legend >Was this page helpful?</legend >
39
39
<div class =" feedback-form-buttons" style =" margin-top: 0;" >
40
+ <input type =" hidden" name =" feedback-value" id =" feedback-value" value =" " />
40
41
<button type =" submit" data-value =" good" style =" margin-top: 0.5rem;" >
41
42
<Icon name =" mdi:emoticon-happy-outline" width =" 32" height =" 32" />
42
43
</button >
@@ -58,7 +59,7 @@ import { Icon } from 'astro-icon/components';
58
59
59
60
function onFormSubmit(e: SubmitEvent) {
60
61
e.preventDefault();
61
- const value = e.submitter?.dataset .value;
62
+ const value = submitValueField .value;
62
63
trackEvent(`Feedback:${value}`);
63
64
const form = document.querySelector<HTMLFormElement>('.feedback-form');
64
65
(form!.firstElementChild! as HTMLFieldSetElement).disabled = true;
@@ -70,4 +71,12 @@ import { Icon } from 'astro-icon/components';
70
71
71
72
const form = document.querySelector<HTMLFormElement>('.feedback-form');
72
73
form!.addEventListener('submit', onFormSubmit);
74
+
75
+ const submitValueField = document.getElementById('feedback-value') as HTMLInputElement;
76
+
77
+ form!.querySelectorAll('button[type="submit"]').forEach(button => {
78
+ button.addEventListener('click', function(e) {
79
+ submitValueField!.value = (e.target as HTMLButtonElement).getAttribute('data-value')!;
80
+ });
81
+ });
73
82
</script >
You can’t perform that action at this time.
0 commit comments