From bf164988e47042fc0790ccecd052dc1b1c820710 Mon Sep 17 00:00:00 2001 From: Pranav Malewadkar Date: Thu, 7 Nov 2024 13:57:14 -0800 Subject: [PATCH] fix: pass correct key to search (#6027) --- .../__tests__/useLocationDetailView.spec.tsx | 8 ++++---- .../views/LocationDetailView/useLocationDetailView.ts | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/__tests__/useLocationDetailView.spec.tsx b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/__tests__/useLocationDetailView.spec.tsx index 326a9f837bf..09e0a20d963 100644 --- a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/__tests__/useLocationDetailView.spec.tsx +++ b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/__tests__/useLocationDetailView.spec.tsx @@ -87,7 +87,7 @@ const testLocation: LocationState = { type: 'PREFIX', }, path: '', - key: 'item-b/', + key: 'item-b-key/', }; const testStoreState = { @@ -138,7 +138,7 @@ describe('useLocationDetailView', () => { refresh: true, pageSize: EXPECTED_PAGE_SIZE, }, - prefix: 'item-b/', + prefix: 'item-b-key/', }); const state = result.current; @@ -275,7 +275,7 @@ describe('useLocationDetailView', () => { expect(handleListMock).toHaveBeenCalledWith({ config, options: { ...DEFAULT_LIST_OPTIONS, refresh: true }, - prefix: 'item-b/', + prefix: 'item-b-key/', }); }); @@ -551,7 +551,7 @@ describe('useLocationDetailView', () => { delimiter: undefined, search: { filterKey: 'key', query: 'moo' }, }, - prefix: 'item-b/', + prefix: 'item-b-key/', }); expect(handleStoreActionMock).toHaveBeenCalledWith({ type: 'RESET_LOCATION_ITEMS', diff --git a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.ts b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.ts index 805d1a56d00..23a56541af1 100644 --- a/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.ts +++ b/packages/react-storage/src/components/StorageBrowser/views/LocationDetailView/useLocationDetailView.ts @@ -260,8 +260,9 @@ export function useLocationDetailView( delimiter: includeSubfolders ? undefined : listOptions.delimiter, search: { query, filterKey: 'key' as const }, }; + handleReset(); - handleList({ config: getConfig(), prefix, options: searchOptions }); + handleList({ config: getConfig(), prefix: key, options: searchOptions }); dispatchStoreAction({ type: 'RESET_LOCATION_ITEMS' }); }, };