auto close labels dropdown on select but not on checkbox

This commit is contained in:
miloschwartz
2026-05-26 22:47:05 -07:00
parent ae8599c723
commit 0b6a3234a5
2 changed files with 18 additions and 9 deletions

View File

@@ -75,6 +75,7 @@ export function TableLabelsCell({
orgId={orgId}
selectedLabels={localLabels}
toggleLabel={toggleLabel}
onClose={() => handleOpenChange(false)}
/>
</PopoverContent>
</Popover>

View File

@@ -36,6 +36,7 @@ export type LabelsSelectorProps = {
orgId: string;
selectedLabels: SelectedLabel[];
toggleLabel: (newlabel: SelectedLabel, action: "detach" | "attach") => void;
onClose?: () => void;
};
export const LABEL_COLORS = {
@@ -51,7 +52,8 @@ export const LABEL_COLORS = {
export function LabelsSelector({
orgId,
selectedLabels,
toggleLabel
toggleLabel,
onClose
}: LabelsSelectorProps) {
const t = useTranslations();
const [labelSearchQuery, setlabelsSearchQuery] = useState("");
@@ -200,18 +202,24 @@ export function LabelsSelector({
? "detach"
: "attach"
);
// } else {
// onSelectionChange([
// ...selectedLabels,
// label
// ]);
// }
onClose?.();
}}
>
<Checkbox
className="pointer-events-none shrink-0"
className="shrink-0"
checked={selectedIds.has(label.labelId)}
onCheckedChange={() => {}}
onClick={(e) => {
e.stopPropagation();
}}
onPointerDown={(e) => {
e.stopPropagation();
}}
onCheckedChange={(checked) => {
toggleLabel(
label,
checked ? "attach" : "detach"
);
}}
aria-hidden
tabIndex={-1}
/>