Skip to content

Commit f5a2ef7

Browse files
critesjoshcritesjosh
authored andcommitted
fix(docs): lock both feedback buttons after a vote
Disable both thumbs-up/thumbs-down after the first click and short-circuit duplicate handleFeedback calls so users cannot flip their vote and re-POST to honk-ai's /api/feedback (which upserts).
1 parent 85c9327 commit f5a2ef7

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

docs/src/components/AztecDocsWidget/Message.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function AssistantBody({
5151
<button
5252
type="button"
5353
onClick={() => onFeedback?.(kind)}
54-
disabled={!onFeedback || active}
54+
disabled={!onFeedback || !!feedback}
5555
title={label}
5656
aria-label={label}
5757
aria-pressed={active}
@@ -60,11 +60,9 @@ export function AssistantBody({
6060
height: 26,
6161
padding: 0,
6262
border: `1px solid ${isInk ? "rgba(242,238,225,0.2)" : "var(--azw-ink-tint-1)"}`,
63-
background: active
64-
? accentColor
65-
: "transparent",
63+
background: active ? accentColor : "transparent",
6664
color: active ? "var(--azw-ink)" : dimmed ? panelFg2 : panelFg,
67-
cursor: onFeedback && !active ? "pointer" : "default",
65+
cursor: onFeedback && !feedback ? "pointer" : "default",
6866
display: "flex",
6967
alignItems: "center",
7068
justifyContent: "center",

docs/src/components/AztecDocsWidget/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export default function AztecDocsWidget({
132132

133133
async function handleFeedback(messageIndex, kind) {
134134
if (!conversationId) return;
135+
if (feedbackByIndex[messageIndex]) return;
135136
setFeedbackByIndex((prev) => ({ ...prev, [messageIndex]: kind }));
136137
setFeedbackErrorsByIndex((prev) => {
137138
if (!prev[messageIndex]) return prev;

0 commit comments

Comments
 (0)