[v9.4.x] Search: Fix not being able to clear sort value (#62869)
Search: Fix not being able to clear sort value (#62557)
* user essentials mob! 🔱
lastFile:public/app/features/search/state/SearchStateManager.ts
* user essentials mob! 🔱
lastFile:public/app/features/search/page/components/ActionRow.tsx
* user essentials mob! 🔱
* remove searchSort state from localStorage when cleared
---------
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
Co-authored-by: Joao Silva <joao.silva@grafana.com>
(cherry picked from commit f8809eef59)
Co-authored-by: Josh Hunt <joshhunt@users.noreply.github.com>
This commit is contained in:
co-authored by
Josh Hunt
parent
9cf5b4eb9e
commit
00555606d5
@@ -106,10 +106,10 @@ export const ActionRow: FC<Props> = ({
|
||||
/>
|
||||
)}
|
||||
<SortPicker
|
||||
onChange={(change) => onSortChange(change.value)}
|
||||
onChange={(change) => onSortChange(change?.value)}
|
||||
value={state.sort}
|
||||
getSortOptions={getSortOptions}
|
||||
placeholder={sortPlaceholder}
|
||||
placeholder={sortPlaceholder || 'Sort'}
|
||||
isClearable
|
||||
/>
|
||||
</HorizontalGroup>
|
||||
|
||||
@@ -115,6 +115,8 @@ export class SearchStateManager extends StateManagerBase<SearchState> {
|
||||
onSortChange = (sort: string | undefined) => {
|
||||
if (sort) {
|
||||
localStorage.setItem(SEARCH_SELECTED_SORT, sort);
|
||||
} else {
|
||||
localStorage.removeItem(SEARCH_SELECTED_SORT);
|
||||
}
|
||||
|
||||
if (this.state.layout === SearchLayout.Folders) {
|
||||
@@ -171,10 +173,6 @@ export class SearchStateManager extends StateManagerBase<SearchState> {
|
||||
q.kind = ['dashboard', 'folder']; // skip panels
|
||||
}
|
||||
|
||||
if (q.query === '*' && !q.sort?.length) {
|
||||
q.sort = 'name_sort';
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user