Skip to content

Commit b825918

Browse files
Merge pull request #11240 from mendix/olu-feedback-widget-fix
Fix: hidden feedback widget and unresponsive button click
2 parents 7007079 + 4c997d6 commit b825918

2 files changed

Lines changed: 36 additions & 30 deletions

File tree

layouts/docs/list.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ <h1>{{ .Title }}</h1>
1111
</header>
1212
{{ .Content }}
1313
{{ partial "section-index.html" . }}
14-
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable) (.Site.Config.Services.GoogleAnalytics.ID)) }}
14+
<!-- Olu: removed checking for .Site.Config.Services.GoogleAnalytics.ID as part of the conditions -->
15+
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable)) }}
1516
{{ partial "feedback.html" .Site.Params.ui.feedback }}
1617
<br />
1718
{{ end }}

layouts/partials/feedback.html

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -66,35 +66,40 @@ <h2 class="feedback--title">Feedback</h2>
6666

6767
<!-- NK - document.querySelector lines grab feedback issue link generated from page-meta-links.html -->
6868
<script>
69-
document.querySelector('.feedback--link').href = document.querySelector('a.feedback-issue').href;
70-
const yesButton = document.querySelector('.feedback--answer-yes');
71-
const noButton = document.querySelector('.feedback--answer-no');
72-
const yesResponse = document.querySelector('.feedback--response-yes');
73-
const noResponse = document.querySelector('.feedback--response-no');
74-
const disableButtons = () => {
75-
yesButton.disabled = true;
76-
noButton.disabled = true;
77-
};
78-
const sendFeedback = (value) => {
79-
if (typeof ga !== 'function') return;
80-
const args = {
81-
command: 'send',
82-
hitType: 'event',
83-
category: 'Helpful',
84-
action: 'click',
85-
label: window.location.pathname,
86-
value: value
69+
document.addEventListener('DOMContentLoaded', function () {
70+
const feedbackIssueLink = document.querySelector('a.feedback-issue');
71+
if (feedbackIssueLink) {
72+
document.querySelector('.feedback--link').href = feedbackIssueLink.href;
73+
}
74+
const yesButton = document.querySelector('.feedback--answer-yes');
75+
const noButton = document.querySelector('.feedback--answer-no');
76+
const yesResponse = document.querySelector('.feedback--response-yes');
77+
const noResponse = document.querySelector('.feedback--response-no');
78+
const disableButtons = () => {
79+
yesButton.disabled = true;
80+
noButton.disabled = true;
8781
};
88-
ga(args.command, args.hitType, args.category, args.action, args.label, args.value);
89-
};
90-
yesButton.addEventListener('click', () => {
91-
yesResponse.classList.add('feedback--response__visible');
92-
disableButtons();
93-
sendFeedback(1);
94-
});
95-
noButton.addEventListener('click', () => {
96-
noResponse.classList.add('feedback--response__visible');
97-
disableButtons();
98-
sendFeedback(0);
82+
const sendFeedback = (value) => {
83+
if (typeof ga !== 'function') return;
84+
const args = {
85+
command: 'send',
86+
hitType: 'event',
87+
category: 'Helpful',
88+
action: 'click',
89+
label: window.location.pathname,
90+
value: value
91+
};
92+
ga(args.command, args.hitType, args.category, args.action, args.label, args.value);
93+
};
94+
yesButton.addEventListener('click', () => {
95+
yesResponse.classList.add('feedback--response__visible');
96+
disableButtons();
97+
sendFeedback(1);
98+
});
99+
noButton.addEventListener('click', () => {
100+
noResponse.classList.add('feedback--response__visible');
101+
disableButtons();
102+
sendFeedback(0);
103+
});
99104
});
100105
</script>

0 commit comments

Comments
 (0)