From d1c355b21340f8f55ef31da445b3ba8bdfd38559 Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Wed, 8 Jun 2022 13:43:45 +0200 Subject: [PATCH] Calling search results without parameters (#2056) Calling search results without parameters leads to "Cannot read properties of undefined (reading 'length')" error. It does not matter which search mask is called. --- gradle/changelog/empty_search.yaml | 2 ++ scm-ui/ui-api/src/search.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 gradle/changelog/empty_search.yaml diff --git a/gradle/changelog/empty_search.yaml b/gradle/changelog/empty_search.yaml new file mode 100644 index 0000000000..30dd058591 --- /dev/null +++ b/gradle/changelog/empty_search.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Calling search results without parameters ([#2056](https://github.com/scm-manager/scm-manager/pull/2056)) diff --git a/scm-ui/ui-api/src/search.ts b/scm-ui/ui-api/src/search.ts index e32d2d8dc7..167cf5dade 100644 --- a/scm-ui/ui-api/src/search.ts +++ b/scm-ui/ui-api/src/search.ts @@ -113,7 +113,7 @@ export const useSearch = (query: string, optionParam = defaultSearchOptions): Ap ["search", options.type, queryParams], () => apiClient.get(`${link}?${createQueryString(queryParams)}`).then((response) => response.json()), { - enabled: query.length > 1, + enabled: query?.length > 1, } ); };