From e5469f3782bbd0030b05492ef834f20d594a5aaa Mon Sep 17 00:00:00 2001 From: Haohan Yang Date: Mon, 23 Sep 2024 08:32:00 +0000 Subject: [PATCH] fix query editor error bug --- src/components/QueryEditor.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/QueryEditor.tsx b/src/components/QueryEditor.tsx index cd732f0..a5db46a 100644 --- a/src/components/QueryEditor.tsx +++ b/src/components/QueryEditor.tsx @@ -32,11 +32,12 @@ export function QueryEditor({ query, onChange }: Props) { const queryJson = JSON.parse(queryText); if (!Array.isArray(queryJson)) { + setQueryTextError("Invalid query"); + } else { setQueryTextError(null); } - setQueryTextError("This is not a valid Mongo Aggregation Pipeline"); } catch (e) { - setQueryTextError("This is not a valid Mongo Aggregation Pipeline"); + setQueryTextError("Invalid query"); } } }; @@ -81,9 +82,9 @@ export function QueryEditor({ query, onChange }: Props) { + error={queryTextError} invalid={queryTextError != null}> + onBlur={onQueryTextChange} value={queryText || ""} showMiniMap={false} />