Skip to content

Commit

Permalink
Sync query and filter when refreshing discover page (#8168)
Browse files Browse the repository at this point in the history
* revert back to use savedSearch

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>

* change to use savedSearchId

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>

* Changeset file for PR #8168 created/updated

* revert to use savesearch

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>

---------

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 18875f7)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 8386b12 commit 0f69bfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8168.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Sync query and filter when refreshing discover page ([#8168](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8168))
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ export const useSearch = (services: DiscoverViewServices) => {
const savedSearchInstance = await getSavedSearchById(savedSearchId);
setSavedSearch(savedSearchInstance);

// if saved search does not exist, do not atempt to sync filters and query from savedObject
if (!savedSearch) {
return;

Check warning on line 329 in src/plugins/discover/public/application/view_components/utils/use_search.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/discover/public/application/view_components/utils/use_search.ts#L329

Added line #L329 was not covered by tests
}

// sync initial app filters from savedObject to filterManager
const filters = cloneDeep(savedSearchInstance.searchSource.getOwnField('filter'));
const query =
Expand Down

0 comments on commit 0f69bfb

Please sign in to comment.