From 731c884dfe42f364581469735b96f6ffded03ac8 Mon Sep 17 00:00:00 2001 From: marthasharkey Date: Thu, 21 Nov 2024 15:49:06 +0000 Subject: [PATCH] use equals when only one item is selected in filter dropdown (#11613) --- .../components/visualizations/tableVizToolbar.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/gui/src/project-view/components/visualizations/tableVizToolbar.ts b/app/gui/src/project-view/components/visualizations/tableVizToolbar.ts index 93982352ab2..74e8d7a911a 100644 --- a/app/gui/src/project-view/components/visualizations/tableVizToolbar.ts +++ b/app/gui/src/project-view/components/visualizations/tableVizToolbar.ts @@ -5,6 +5,7 @@ import { Ast } from '@/util/ast' import { Pattern } from '@/util/ast/match' import type { ToValue } from '@/util/reactivity' import { computed, type ComputedRef, type Ref, toValue } from 'vue' +import { Expression, MutableExpression } from 'ydoc-shared/ast' type SortDirection = 'asc' | 'desc' export type SortModel = { @@ -78,6 +79,16 @@ function useSortFilterNodesButton({ ]) } const valueFormatter = getColumnValueToEnso(columnName) + if (items?.length === 1) { + const item = items[0] + if (item) { + return filterPattern.value.instantiateCopied([ + Ast.TextLiteral.new(columnName), + Ast.parseExpression('..Equal')!, + valueFormatter(item, module) as Expression | MutableExpression, + ]) + } + } const itemList = items.map((i) => valueFormatter(i, module)) return filterPattern.value.instantiateCopied([ Ast.TextLiteral.new(columnName),