Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): Improve behavior unselecting last filter option (#19204)

Ben Bachem7d65be1d0d4e
diff --git a/web/src/features/filters/lib/sidebar-filter-actions.clienttest.ts b/web/src/features/filters/lib/sidebar-filter-actions.clienttest.ts
index ebf0b3c66f..6de0a7ffb8 100644
--- a/web/src/features/filters/lib/sidebar-filter-actions.clienttest.ts
+++ b/web/src/features/filters/lib/sidebar-filter-actions.clienttest.ts
@@ -278,6 +278,56 @@ describe("applySelection", () => {
});
describe("applyCheckboxSelection", () => {
+ it("keeps excluding user IDs when the last value is unchecked and clears on re-selection", () => {
+ const userCtx: SidebarFilterActionContext = {
+ facets: [{ type: "categorical", column: "userId", label: "User ID" }],
+ columnDefinitions: [
+ {
+ id: "userId",
+ name: "User ID",
+ type: "stringOptions",
+ options: [],
+ internal: "user_id",
+ },
+ ],
+ options: { userId: ["user-a", "user-b"] },
+ };
+ const first = applyCheckboxSelection(userCtx, [], "userId", ["user-b"]);
+ expect(first).toEqual([
+ {
+ column: "userId",
+ type: "stringOptions",
+ operator: "none of",
+ value: ["user-a"],
+ },
+ ]);
+ const second = applyCheckboxSelection(userCtx, first, "userId", []);
+ expect(second).toEqual([{ ...first[0], value: ["user-a", "user-b"] }]);
+ const reselected = applyCheckboxSelection(userCtx, second, "userId", [
+ "user-a",
+ ]);
+ expect(reselected).toEqual([{ ...first[0], value: ["user-b"] }]);
+ expect(
+ applyCheckboxSelection(userCtx, reselected, "userId", [
+ "user-a",
+ "user-b",
+ ]),
+ ).toEqual([]);
+ });
+
+ it("keeps the managed environment reset when the last value is unchecked", () => {
+ const managedCtx = { ...ctx, managedEnvironmentColumn: "env" };
+ const current: FilterState = [
+ {
+ column: "env",
+ type: "stringOptions",
+ operator: "none of",
+ value: ["prod", "dev"],
+ },
+ ];
+ expect(applyCheckboxSelection(managedCtx, current, "env", [])).toEqual([]);
+ });
+
it("drops the column's text filters before applying the selection", () => {
const current: FilterState = [
{ column: "env", type: "string", operator: "contains", value: "pr" },
diff --git a/web/src/features/filters/lib/sidebar-filter-actions.ts b/web/src/features/filters/lib/sidebar-filter-actions.ts
index e0871a1525..67c2f129a9 100644
--- a/web/src/features/filters/lib/sidebar-filter-actions.ts
+++ b/web/src/features/filters/lib/sidebar-filter-actions.ts
@@ -274,9 +274,8 @@ export function applySelection(
// "no filter": exclusions outside the current option list may still be
// live. Skip the all-selected removal shortcut and let
// resolveCheckboxOperator re-derive the exclusion set (an emptied set is
- // removed below). For arrayOptions this also covers "none checked",
- // which means exclude-everything rather than reset; stringOptions keeps
- // its long-standing uncheck-everything-resets behavior. The managed
+ // removed below). This also covers "none checked", which means
+ // exclude every listed value rather than reset. The managed
// environment column is exempt: its all-selected shortcut persists the
// explicit enable-all-environments override, and its hidden
// environments are always listed, so there is nothing to carry.
@@ -287,7 +286,6 @@ export function applySelection(
(colType !== "arrayOptions" &&
existingFilter?.type === "stringOptions" &&
existingFilter.operator === "none of" &&
- values.length > 0 &&
!isManagedEnvironmentColumn);
if (operator !== undefined) {