🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix: add select all to multi select dropdown (#8004)
Nimarbeb2063dcbfd
diff --git a/web/src/features/filters/components/multi-select.tsx b/web/src/features/filters/components/multi-select.tsxindex 701cb1774e..959b85e846 100644--- a/web/src/features/filters/components/multi-select.tsx+++ b/web/src/features/filters/components/multi-select.tsx@@ -21,7 +21,7 @@ import {import { Separator } from "@/src/components/ui/separator";import { type FilterOption } from "@langfuse/shared";import { Input } from "@/src/components/ui/input";-import { useRef, useState } from "react";+import { useRef, useState, useMemo, useCallback } from "react";import { PropertyHoverCard } from "@/src/features/widgets/components/WidgetPropertySelectItem";const getFreeTextInput = (@@ -54,7 +54,7 @@ export function MultiSelect({isCustomSelectEnabled?: boolean;labelTruncateCutOff?: number;}) {- const selectedValues = new Set(values);+ const selectedValues = useMemo(() => new Set(values), [values]);const optionValues = new Set(options.map((option) => option.value));const freeTextInput = getFreeTextInput(isCustomSelectEnabled,@@ -63,6 +63,35 @@ export function MultiSelect({);const [freeText, setFreeText] = useState(freeTextInput || "");+ const selectableOptions = useMemo(+ () => options.filter((option) => option.value.length > 0),+ [options],+ );++ const allSelectedState = useMemo(() => {+ if (selectableOptions.length === 0) return false;+ return selectableOptions.every((option) =>+ selectedValues.has(option.value),+ );+ }, [selectableOptions, selectedValues]);++ const handleSelectAll = useCallback(() => {+ const newSelectedValues = new Set(selectedValues);+ if (allSelectedState) {+ // Deselect all selectable options+ selectableOptions.forEach((option) =>+ newSelectedValues.delete(option.value),+ );+ } else {+ // Select all selectable options+ selectableOptions.forEach((option) =>+ newSelectedValues.add(option.value),+ );+ }+ const filterValues = Array.from(newSelectedValues);+ onValueChange(filterValues.length ? filterValues : []);+ }, [allSelectedState, selectableOptions, selectedValues, onValueChange]);+const debounceTimeout = useRef<NodeJS.Timeout | null>(null);const handleDebouncedChange = (value: string) => {const freeTextInput = getFreeTextInput(@@ -150,6 +179,26 @@ export function MultiSelect({<InputCommandEmpty>No results found.</InputCommandEmpty>)}<InputCommandGroup>+ {selectableOptions.length > 0 && (+ <>+ <InputCommandItem key="select-all" onSelect={handleSelectAll}>+ <div+ className={cn(+ "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",+ allSelectedState+ ? "bg-primary text-primary-foreground"+ : "opacity-50 [&_svg]:invisible",+ )}+ >+ <Check className={cn("h-4 w-4")} />+ </div>+ <div className="font-medium">+ {allSelectedState ? "Deselect All" : "Select All"}+ </div>+ </InputCommandItem>+ <InputCommandSeparator />+ </>+ )}{options.map((option) => {if (option.value.length === 0) return;const isSelected = selectedValues.has(option.value);