Fix checkbox confirmation bounds handling

This commit is contained in:
Dotta committed 2026-06-06 13:29:50 +00:00
1 parent 6f0df16afb
commit 63b9e55ab7
5 files changed
+23 -1

No files matched your search

@@ -209,6 +209,15 @@ describe("issue thread interaction schemas", () => {
},
})).toThrow("defaultSelectedOptionIds must reference existing option ids");
expect(() => createIssueThreadInteractionSchema.parse({
...base,
payload: {
...base.payload,
defaultSelectedOptionIds: ["item-1"],
minSelected: 2,
},
})).toThrow("defaultSelectedOptionIds must satisfy minSelected");
expect(() => createIssueThreadInteractionSchema.parse({
...base,
payload: {
+7
View File
@@ -795,6 +795,13 @@ export const requestCheckboxConfirmationPayloadSchema = z.object({
path: ["minSelected"],
});
}
if (value.defaultSelectedOptionIds.length < value.minSelected) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "defaultSelectedOptionIds must satisfy minSelected",
path: ["defaultSelectedOptionIds"],
});
}
if (maxSelected != null) {
if (maxSelected < value.minSelected) {
ctx.addIssue({
@@ -820,6 +820,7 @@ describeEmbeddedPostgres("issueThreadInteractionService", () => {
{ id: "two", label: "Two" },
{ id: "three", label: "Three" },
],
defaultSelectedOptionIds: ["one"],
minSelected: 1,
maxSelected: 2,
},
@@ -442,6 +442,11 @@ describe("IssueThreadInteractionCard", () => {
.filter((box) => box.getAttribute("aria-checked") === "false");
expect(stillUnchecked.length).toBeGreaterThan(0);
expect(stillUnchecked.every((box) => box.hasAttribute("disabled"))).toBe(true);
const selectAllButton = Array.from(host.querySelectorAll("button")).find((button) =>
button.textContent?.includes("Select all"),
);
expect(selectAllButton?.hasAttribute("disabled")).toBe(true);
});
it("summarizes large accepted selections by count and bounds the chips", () => {
@@ -1611,7 +1611,7 @@ function RequestCheckboxConfirmationCard({
<Button
size="sm"
variant="ghost"
disabled={working !== null || selectedCount === totalOptions}
disabled={working !== null || selectedCount === totalOptions || (maxSelected != null && selectedCount >= maxSelected)}
onClick={handleSelectAll}
>
Select all