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
+8 -1
+8 -1
View File
@@ -29,30 +29,37 @@ 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) {
if (showForm) {
setLoading(true); 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 () {
if (showForm) {
setLoading(false); setLoading(false);
setShowForm(false); setShowForm(false);
setSubmittedFeedback(true); setSubmittedFeedback(true);
}
}) })
} else { } else {
if (showForm) {
setShowForm(false); setShowForm(false);
setSubmittedFeedback(true); setSubmittedFeedback(true);
} }
} }
} }
}
return ( return (
<div className='feedback-container'> <div className='feedback-container'>