docs: changed behavior of feedback component (#2929)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2023-01-03 13:09:47 +02:00
1 parent cd32795595
commit 82d66408f9
1 file changed
+14 -7
+14 -7
View File
@@ -29,27 +29,34 @@ export default function Feedback ({
const location = useLocation(); const location = useLocation();
function handleFeedback (e) { function handleFeedback (e) {
submitFeedback()
setPositiveFeedbac(e.target.classList.contains('positive')); setPositiveFeedbac(e.target.classList.contains('positive'));
setShowForm(true); setShowForm(true);
} }
function submitFeedback (e) { function submitFeedback () {
if (isBrowser) { if (isBrowser) {
if (window.analytics) { if (window.analytics) {
setLoading(true); if (showForm) {
setLoading(true);
}
window.analytics.track(event, { window.analytics.track(event, {
url: location.pathname, url: location.pathname,
label: document.title, label: document.title,
feedback: positiveFeedback ? 'yes' : 'no', feedback: positiveFeedback ? 'yes' : 'no',
message message
}, function () { }, function () {
setLoading(false); if (showForm) {
setShowForm(false); setLoading(false);
setSubmittedFeedback(true); setShowForm(false);
setSubmittedFeedback(true);
}
}) })
} else { } else {
setShowForm(false); if (showForm) {
setSubmittedFeedback(true); setShowForm(false);
setSubmittedFeedback(true);
}
} }
} }
} }