diff --git a/public/app/plugins/datasource/loki/components/LokiLabel.tsx b/public/app/plugins/datasource/loki/components/LokiLabel.tsx index 8acb986d56a6d..fc63b3bf96b8e 100644 --- a/public/app/plugins/datasource/loki/components/LokiLabel.tsx +++ b/public/app/plugins/datasource/loki/components/LokiLabel.tsx @@ -14,7 +14,7 @@ export interface Props extends Omit, 'onClick'> { name: string; active?: boolean; loading?: boolean; - searchTerm?: RegExp; + searchTerm?: string; value?: string; facets?: number; onClick?: OnLabelClick; @@ -24,6 +24,7 @@ export const LokiLabel = forwardRef( ({ name, value, hidden, facets, onClick, className, loading, searchTerm, active, style, ...rest }, ref) => { const theme = useTheme(); const styles = getLabelStyles(theme); + const searchWords = searchTerm ? [searchTerm] : []; const onLabelClick = (event: React.MouseEvent) => { if (onClick && !hidden) { @@ -55,7 +56,7 @@ export const LokiLabel = forwardRef( )} {...rest} > - + ); } diff --git a/public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx b/public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx index f37e992bf6538..ea1eeb7ae7a4c 100644 --- a/public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx +++ b/public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx @@ -364,17 +364,13 @@ export class UnthemedLokiLabelBrowser extends React.Component; } const styles = getStyles(theme); - let matcher: RegExp; let selectedLabels = labels.filter((label) => label.selected && label.values); if (searchTerm) { // TODO extract from render() and debounce - try { - matcher = new RegExp(searchTerm.split('').join('.*'), 'i'); - selectedLabels = selectedLabels.map((label) => ({ - ...label, - values: label.values?.filter((value) => value.selected || matcher.test(value.name)), - })); - } catch (error) {} + selectedLabels = selectedLabels.map((label) => ({ + ...label, + values: label.values?.filter((value) => value.selected || value.name.includes(searchTerm)), + })); } const selector = buildSelector(this.state.labels); const empty = selector === EMPTY_SELECTOR; @@ -439,7 +435,7 @@ export class UnthemedLokiLabelBrowser extends React.Component );