mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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>
This commit is contained in:
@@ -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