From 4c9f112103de986ba40e55f54ac8237fe8e258e5 Mon Sep 17 00:00:00 2001 From: "Simone (Saxos)" <80248336+Saxos-Simone@users.noreply.github.com> Date: Sun, 31 Aug 2025 16:35:16 +0200 Subject: [PATCH] fix(filter): don't crash when filtering for labels in (#1333) --- .../components/input/filter/highlighter.ts | 59 +------------------ 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/frontend/src/components/input/filter/highlighter.ts b/frontend/src/components/input/filter/highlighter.ts index 7aa694872..e0372c052 100644 --- a/frontend/src/components/input/filter/highlighter.ts +++ b/frontend/src/components/input/filter/highlighter.ts @@ -83,64 +83,9 @@ function decorateDocument(doc: Node) { while ((labelMatch = pattern.exec(text)) !== null) { const labelValue = labelMatch[4]?.trim() const operator = labelMatch[2]?.trim() - if (labelValue) { // If there's a value - const valueStart = labelMatch.index + labelMatch[0].lastIndexOf(labelValue) - const valueEnd = valueStart + labelValue.length - const addLabelDecoration = (labelValue: string, start: number, end: number) => { - const label = labelStore.getLabelByExactTitle(labelValue) - - const from = findPosForIndex(doc, start) - const to = findPosForIndex(doc, end) - - if (from === null || to === null) { - return - } - - valueRanges.push({start, end}) - - 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'};`, - }), - ) - - return - } - - // Fallback to generic value styling - decorations.push( - Decoration.inline(from, to, {class: 'value'}), - ) - } - - // Check if this is a multi-value operator and the value contains commas - const isMultiValueOperator = ['in', '?=', 'not in', '?!='].includes(operator) - if (isMultiValueOperator && labelValue.includes(',')) { - // Split by commas and create decorations for each individual label - const labels = labelValue.split(',').map(l => l.trim()).filter(l => l.length > 0) - let currentOffset = 0 - - labels.forEach(individualLabel => { - // Find the position of this individual label within the full value - const labelIndex = labelValue.indexOf(individualLabel, currentOffset) - if (labelIndex !== -1) { - const individualStart = valueStart + labelIndex - const individualEnd = individualStart + individualLabel.length - - addLabelDecoration(individualLabel, individualStart, individualEnd) - - currentOffset = labelIndex + individualLabel.length - } - }) - - continue - } - - addLabelDecoration(labelValue, valueStart, valueEnd) + if(!labelValue) { + continue } const valueStart = labelMatch.index + labelMatch[0].lastIndexOf(labelValue)