Keep checkbox summary toggle focus stable

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-06-06 19:45:59 +00:00
1 parent 2df38c0e66
commit 4b21981b32
2 files changed
+11 -18

No files matched your search

@@ -480,6 +480,8 @@ describe("IssueThreadInteractionCard", () => {
button.textContent?.includes("+34 more"),
);
expect(moreButton).toBeTruthy();
moreButton?.focus();
expect(document.activeElement).toBe(moreButton);
act(() => {
moreButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
@@ -487,11 +489,13 @@ describe("IssueThreadInteractionCard", () => {
expect(host.textContent).not.toContain("+34 more");
expect(countSelectedChips()).toBe(42);
expect(document.activeElement).toBe(moreButton);
const showLessButton = Array.from(host.querySelectorAll("button")).find((button) =>
button.textContent?.includes("Show less"),
);
expect(showLessButton).toBeTruthy();
expect(showLessButton).toBe(moreButton);
act(() => {
showLessButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
@@ -499,6 +503,7 @@ describe("IssueThreadInteractionCard", () => {
expect(countSelectedChips()).toBe(8);
expect(host.textContent).toContain("+34 more");
expect(document.activeElement).toBe(moreButton);
});
it("stays compact and scrollable with around 100 options", () => {
@@ -1347,7 +1347,8 @@ function RequestCheckboxConfirmationResolution({
const visibleLabels = expanded
? selectedLabels
: selectedLabels.slice(0, CHECKBOX_SUMMARY_LABEL_LIMIT);
const hiddenCount = selectedLabels.length - visibleLabels.length;
const hiddenCount = selectedLabels.length - CHECKBOX_SUMMARY_LABEL_LIMIT;
const hasHiddenLabels = hiddenCount > 0;
const chipClassName =
"inline-flex items-center rounded-sm border border-border/60 bg-transparent px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-muted-foreground";
@@ -1366,30 +1367,17 @@ function RequestCheckboxConfirmationResolution({
{visibleLabels.map((label, index) => (
<TaskField key={`${label}-${index}`} label="Selected" value={label} />
))}
{hiddenCount > 0 ? (
{hasHiddenLabels ? (
<button
type="button"
onClick={() => setExpanded(true)}
onClick={() => setExpanded((current) => !current)}
className={cn(
chipClassName,
"cursor-pointer transition-colors hover:border-border hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
)}
aria-expanded={false}
aria-expanded={expanded}
>
+{hiddenCount} more
</button>
) : null}
{expanded && selectedLabels.length > CHECKBOX_SUMMARY_LABEL_LIMIT ? (
<button
type="button"
onClick={() => setExpanded(false)}
className={cn(
chipClassName,
"cursor-pointer transition-colors hover:border-border hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
)}
aria-expanded={true}
>
Show less
{expanded ? "Show less" : `+${hiddenCount} more`}
</button>
) : null}
</div>