From 0fa437b8a2ed7845d83d50eb3e2cb0c0119f7f1b Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 10 Aug 2025 15:51:28 +0200 Subject: [PATCH] fix(filter): don't treat ' ' as label value --- .../components/input/filter/highlighter.ts | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/input/filter/highlighter.ts b/frontend/src/components/input/filter/highlighter.ts index cc963717a..19124dd1e 100644 --- a/frontend/src/components/input/filter/highlighter.ts +++ b/frontend/src/components/input/filter/highlighter.ts @@ -80,11 +80,34 @@ function decorateDocument(doc: Node) { const pattern = getFilterFieldRegexPattern(labelField) let labelMatch while ((labelMatch = pattern.exec(text)) !== null) { - const labelValue = labelMatch[5]?.trim() - const operator = labelMatch[2]?.trim() + const labelValue = labelMatch[4]?.trim() + if (labelValue) { // If there's a value + const valueStart = labelMatch.index + labelMatch[0].indexOf(labelValue) + const valueEnd = valueStart + labelValue.length - if (!labelValue) { - continue + // Find the label by its title + const label = labelStore.getLabelByExactTitle(labelValue) + + const from = findPosForIndex(doc, valueStart) + const to = findPosForIndex(doc, valueEnd) + + if (from !== null && to !== null) { + if (label) { + // Use label color if found + decorations.push( + Decoration.inline(from, to, { + class: 'label-value', + style: `background-color: ${label.hexColor}; color: ${label.hexColor && colorIsDark(label.hexColor) ? 'white' : 'black'};`, + }), + ) + } else { + // Fallback to generic value styling + decorations.push( + Decoration.inline(from, to, {class: 'value'}), + ) + } + valueRanges.push({start: valueStart, end: valueEnd}) + } } const valueStart = labelMatch.index + labelMatch[0].lastIndexOf(labelValue)