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} orgId={orgId}
selectedLabels={localLabels} selectedLabels={localLabels}
toggleLabel={toggleLabel} toggleLabel={toggleLabel}
onClose={() => handleOpenChange(false)}
/> />
</PopoverContent> </PopoverContent>
</Popover> </Popover>

View File

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