From 00eba89e205acdd7b6fc7be6918fd32487f842bc Mon Sep 17 00:00:00 2001 From: Yunus M Date: Tue, 29 Apr 2025 12:12:58 +0530 Subject: [PATCH] fix: handle . notation keywords better --- .../CodeMirrorWhereClause/CodeMirrorWhereClause.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/QueryBuilderV2/CodeMirrorWhereClause/CodeMirrorWhereClause.tsx b/frontend/src/components/QueryBuilderV2/CodeMirrorWhereClause/CodeMirrorWhereClause.tsx index 0d9735889b60..591a545e5c46 100644 --- a/frontend/src/components/QueryBuilderV2/CodeMirrorWhereClause/CodeMirrorWhereClause.tsx +++ b/frontend/src/components/QueryBuilderV2/CodeMirrorWhereClause/CodeMirrorWhereClause.tsx @@ -407,7 +407,7 @@ function CodeMirrorWhereClause(): JSX.Element { // }; function myCompletions(context: CompletionContext): CompletionResult | null { - const word = context.matchBefore(/\w*/); + const word = context.matchBefore(/[.\w]*/); if (word?.from === word?.to && !context.explicit) return null; // Get the query context at the cursor position @@ -423,17 +423,25 @@ function CodeMirrorWhereClause(): JSX.Element { }[] = []; if (queryContext.isInKey) { - options = keySuggestions || []; + const searchText = word?.text.toLowerCase() ?? ''; + + options = (keySuggestions || []).filter((option) => + option.label.toLowerCase().includes(searchText), + ); + return { from: word?.from ?? 0, + to: word?.to ?? cursorPos.ch, options, }; } if (queryContext.isInOperator) { + options = []; options = queryOperatorSuggestions; return { from: word?.from ?? 0, + to: word?.to ?? cursorPos.ch, options, }; }