Render other answers as text links
This commit is contained in:
@@ -74,7 +74,7 @@ describe("IssueThreadInteractionCard", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const radios = [...host.querySelectorAll('[role="radio"]')];
|
const radios = [...host.querySelectorAll('[role="radio"]')];
|
||||||
expect(radios).toHaveLength(3);
|
expect(radios).toHaveLength(2);
|
||||||
expect(radios[0]?.getAttribute("aria-checked")).toBe("false");
|
expect(radios[0]?.getAttribute("aria-checked")).toBe("false");
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
@@ -88,7 +88,13 @@ describe("IssueThreadInteractionCard", () => {
|
|||||||
expect(multiGroup?.getAttribute("aria-labelledby")).toBe(
|
expect(multiGroup?.getAttribute("aria-labelledby")).toBe(
|
||||||
"interaction-questions-default-post-submit-summary-prompt",
|
"interaction-questions-default-post-submit-summary-prompt",
|
||||||
);
|
);
|
||||||
expect(host.querySelectorAll('[role="checkbox"]')).toHaveLength(4);
|
expect(host.querySelectorAll('[role="checkbox"]')).toHaveLength(3);
|
||||||
|
|
||||||
|
const otherLink = Array.from(host.querySelectorAll("button")).find((button) =>
|
||||||
|
button.textContent === "Other",
|
||||||
|
);
|
||||||
|
expect(otherLink?.getAttribute("role")).toBeNull();
|
||||||
|
expect(otherLink?.className).toContain("underline");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("submits written Other answers for pending questions", async () => {
|
it("submits written Other answers for pending questions", async () => {
|
||||||
|
|||||||
@@ -821,32 +821,40 @@ function AskUserQuestionsCard({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div className="mt-3 space-y-3">
|
||||||
className="mt-3 grid gap-3"
|
<div
|
||||||
role={question.selectionMode === "single" ? "radiogroup" : "group"}
|
className="grid gap-3"
|
||||||
aria-labelledby={`${interaction.id}-${question.id}-prompt`}
|
role={question.selectionMode === "single" ? "radiogroup" : "group"}
|
||||||
>
|
aria-labelledby={`${interaction.id}-${question.id}-prompt`}
|
||||||
{question.options.map((option) => (
|
>
|
||||||
<QuestionOptionButton
|
{question.options.map((option) => (
|
||||||
key={option.id}
|
<QuestionOptionButton
|
||||||
id={`${interaction.id}-${question.id}-${option.id}`}
|
key={option.id}
|
||||||
label={option.label}
|
id={`${interaction.id}-${question.id}-${option.id}`}
|
||||||
description={option.description}
|
label={option.label}
|
||||||
selected={(draftAnswers[question.id] ?? []).includes(option.id)}
|
description={option.description}
|
||||||
selectionMode={question.selectionMode}
|
selected={(draftAnswers[question.id] ?? []).includes(option.id)}
|
||||||
onClick={() =>
|
selectionMode={question.selectionMode}
|
||||||
toggleOption(question.id, option.id, question.selectionMode)}
|
onClick={() =>
|
||||||
/>
|
toggleOption(question.id, option.id, question.selectionMode)}
|
||||||
))}
|
/>
|
||||||
<QuestionOptionButton
|
))}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
id={`${interaction.id}-${question.id}-other`}
|
id={`${interaction.id}-${question.id}-other`}
|
||||||
label="Other"
|
aria-expanded={otherActiveQuestions[question.id] === true}
|
||||||
description="Use a written answer instead of the listed choices."
|
className={cn(
|
||||||
selected={otherActiveQuestions[question.id] === true}
|
"text-sm font-medium underline underline-offset-4 transition-colors outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
||||||
selectionMode={question.selectionMode}
|
otherActiveQuestions[question.id]
|
||||||
|
? "text-sky-700 hover:text-sky-800 dark:text-sky-300 dark:hover:text-sky-200"
|
||||||
|
: "text-muted-foreground hover:text-foreground",
|
||||||
|
)}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
toggleOption(question.id, OTHER_ANSWER_ID, question.selectionMode)}
|
toggleOption(question.id, OTHER_ANSWER_ID, question.selectionMode)}
|
||||||
/>
|
>
|
||||||
|
Other
|
||||||
|
</button>
|
||||||
{otherActiveQuestions[question.id] ? (
|
{otherActiveQuestions[question.id] ? (
|
||||||
<Textarea
|
<Textarea
|
||||||
aria-label={`Other answer for ${question.prompt}`}
|
aria-label={`Other answer for ${question.prompt}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user