Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
20
2 changes: 1 addition & 1 deletion src/components/QueryEditor/FilterEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ interface FilterEditorRowProps {

export const FilterEditorRow = ({ value, onSubmit }: FilterEditorRowProps) => {
const dispatch = useDispatch();
const getFields = useFields('filters', 'startsWith');
const getFields = useFields('filters', 'containsCaseInsensitive');
const valueInputRef = useRef<HTMLInputElement>(null);

return (
Expand Down
17 changes: 15 additions & 2 deletions src/hooks/useFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const toSelectableValue = ({ text }: MetricFindValue): SelectableValue<string> =
value: text,
});

type MatchType = 'contains' | 'startsWith'
type MatchType = 'contains' | 'containsCaseInsensitive' | 'startsWith'

/**
* Returns a function to query the configured datasource for autocomplete values for the specified aggregation type or data types.
Expand All @@ -73,7 +73,20 @@ export const useFields = (type: AggregationType | string[], matchType: MatchType
if (q === undefined) {
return true;
}
return matchType === 'contains' ? text.includes(q) : text.startsWith(q)

switch (matchType) {
case 'contains':
return text.includes(q);

case 'containsCaseInsensitive':
return text.toLowerCase().includes(q.toLowerCase());

case 'startsWith':
return text.startsWith(q);

default:
return true;
}
})
.map(toSelectableValue);
};
Expand Down