Skip to content

Commit

Permalink
32272 Search request display issues
Browse files Browse the repository at this point in the history
- Pass onSubmit down to useLastSavedSearch for intial fetch to fix failing tests
  • Loading branch information
johnphan96 committed Nov 16, 2023
1 parent bc649a2 commit 7b3b0ad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function QueryBuilder({
queryBuilderConfig={queryBuilderConfig}
setSubmittedQueryBuilderTree={setSubmittedQueryBuilderTree}
setPageOffset={setPageOffset}
performSubmit={onSubmit}
/>
<Query
{...queryBuilderConfig}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ interface UseLastSavedSearchProps {
* Set the page offset, used to to load a saved search.
*/
setPageOffset: React.Dispatch<React.SetStateAction<number>>;

/**
* For the last loaded search, we will actually perform the search by calling this callback
* function.
*/
performSubmit: () => void;
}

interface UseLastSavedSearchReturn {
Expand All @@ -37,7 +43,8 @@ export function useLastSavedSearch({
indexName,
setQueryBuilderTree,
setSubmittedQueryBuilderTree,
setPageOffset
setPageOffset,
performSubmit
}: UseLastSavedSearchProps): UseLastSavedSearchReturn {
const localStorageLastUsedTreeKey = indexName + "-last-used-tree";

Expand Down Expand Up @@ -68,6 +75,8 @@ export function useLastSavedSearch({
Utils.loadTree(localStorageQueryTree as JsonTree)
);
setPageOffset(0);
} else {
performSubmit();
}
}, [queryLoaded]);

Expand Down
12 changes: 10 additions & 2 deletions packages/common-ui/lib/list-page/saved-searches/SavedSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export interface SavedSearchProps {
* Set the page offset, used to to load a saved search.
*/
setPageOffset: React.Dispatch<React.SetStateAction<number>>;

/**
* For the last loaded search, we will actually perform the search by calling this callback
* function.
*/
performSubmit: () => void;
}

/**
Expand All @@ -75,7 +81,8 @@ export function SavedSearch({
setQueryBuilderTree,
queryBuilderConfig,
setSubmittedQueryBuilderTree,
setPageOffset
setPageOffset,
performSubmit
}: SavedSearchProps) {
const { save, apiClient } = useApiClient();
const { openModal } = useModal();
Expand Down Expand Up @@ -109,7 +116,8 @@ export function SavedSearch({
indexName,
setQueryBuilderTree,
setSubmittedQueryBuilderTree,
setPageOffset
setPageOffset,
performSubmit
});

// Using the user preferences get the options and user preferences.
Expand Down

0 comments on commit 7b3b0ad

Please sign in to comment.