From f40c5d5b0b38f9eba998fe552b1171b07bab4f34 Mon Sep 17 00:00:00 2001 From: Adeel Nawaz Date: Wed, 23 Oct 2024 11:35:35 +0500 Subject: [PATCH 1/4] fix: saved search name is blank after clearing name field --- src/libs/actions/Search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 0f89232dc3cf..8af9473dff85 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -52,7 +52,7 @@ function getOnyxLoadingData(hash: number): {optimisticData: OnyxUpdate[]; finall } function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: string}) { - const saveSearchName = newName ?? queryJSON?.inputQuery ?? ''; + const saveSearchName = newName?.trim() || queryJSON?.inputQuery || ''; const jsonQuery = JSON.stringify(queryJSON); const optimisticData: OnyxUpdate[] = [ From 0489c4a7a6502bba4736ba33ef4b9a4326f234fc Mon Sep 17 00:00:00 2001 From: Adeel Nawaz Date: Wed, 23 Oct 2024 12:40:10 +0500 Subject: [PATCH 2/4] fix lint --- src/libs/actions/Search.ts | 2 +- src/pages/Search/SavedSearchRenamePage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 8af9473dff85..0f89232dc3cf 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -52,7 +52,7 @@ function getOnyxLoadingData(hash: number): {optimisticData: OnyxUpdate[]; finall } function saveSearch({queryJSON, newName}: {queryJSON: SearchQueryJSON; newName?: string}) { - const saveSearchName = newName?.trim() || queryJSON?.inputQuery || ''; + const saveSearchName = newName ?? queryJSON?.inputQuery ?? ''; const jsonQuery = JSON.stringify(queryJSON); const optimisticData: OnyxUpdate[] = [ diff --git a/src/pages/Search/SavedSearchRenamePage.tsx b/src/pages/Search/SavedSearchRenamePage.tsx index 98a33759682c..19bc862d82db 100644 --- a/src/pages/Search/SavedSearchRenamePage.tsx +++ b/src/pages/Search/SavedSearchRenamePage.tsx @@ -38,7 +38,7 @@ function SavedSearchRenamePage({route}: {route: {params: {q: string; name: strin SearchActions.saveSearch({ queryJSON, - newName, + newName: newName?.trim() || q, }); applyFiltersAndNavigate(); From 1bd270690efee53371dd65c6bc00bf45a404aba7 Mon Sep 17 00:00:00 2001 From: Adeel Nawaz Date: Thu, 24 Oct 2024 22:30:51 +0500 Subject: [PATCH 3/4] trim name param --- src/pages/Search/SavedSearchRenamePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Search/SavedSearchRenamePage.tsx b/src/pages/Search/SavedSearchRenamePage.tsx index 19bc862d82db..7b2cdbc620b1 100644 --- a/src/pages/Search/SavedSearchRenamePage.tsx +++ b/src/pages/Search/SavedSearchRenamePage.tsx @@ -28,7 +28,7 @@ function SavedSearchRenamePage({route}: {route: {params: {q: string; name: strin Navigation.navigate( ROUTES.SEARCH_CENTRAL_PANE.getRoute({ query: q, - name: newName, + name: newName.trim(), }), ); }; From 1931d55d6627b0287a6b254d36bdb4eafdb6aabf Mon Sep 17 00:00:00 2001 From: Adeel Nawaz Date: Thu, 24 Oct 2024 22:57:12 +0500 Subject: [PATCH 4/4] use optional chaining operator --- src/pages/Search/SavedSearchRenamePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Search/SavedSearchRenamePage.tsx b/src/pages/Search/SavedSearchRenamePage.tsx index 7b2cdbc620b1..0d9399965757 100644 --- a/src/pages/Search/SavedSearchRenamePage.tsx +++ b/src/pages/Search/SavedSearchRenamePage.tsx @@ -28,7 +28,7 @@ function SavedSearchRenamePage({route}: {route: {params: {q: string; name: strin Navigation.navigate( ROUTES.SEARCH_CENTRAL_PANE.getRoute({ query: q, - name: newName.trim(), + name: newName?.trim(), }), ); };