Search: Fix select item pressing enter 404 (#24634)

* Remove appSubUrl for navigation

* stripBaseFromUrl

* Remove unused imports
This commit is contained in:
Tobias Skarhed 2020-05-14 11:17:09 +02:00 committed by GitHub
parent f1386c7892
commit 37a2ac20c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import { MOVE_SELECTION_DOWN, MOVE_SELECTION_UP } from '../reducers/actionTypes'
import { dashboardsSearchState, DashboardsSearchState, searchReducer } from '../reducers/dashboardSearch'; import { dashboardsSearchState, DashboardsSearchState, searchReducer } from '../reducers/dashboardSearch';
import { findSelected } from '../utils'; import { findSelected } from '../utils';
import { useSearch } from './useSearch'; import { useSearch } from './useSearch';
import { locationUtil } from '@grafana/data';
export const useDashboardSearch = (query: DashboardQuery, onCloseSearch: () => void) => { export const useDashboardSearch = (query: DashboardQuery, onCloseSearch: () => void) => {
const reducer = useReducer(searchReducer, dashboardsSearchState); const reducer = useReducer(searchReducer, dashboardsSearchState);
@ -31,7 +32,9 @@ export const useDashboardSearch = (query: DashboardQuery, onCloseSearch: () => v
if (selectedItem.type === DashboardSearchItemType.DashFolder) { if (selectedItem.type === DashboardSearchItemType.DashFolder) {
onToggleSection(selectedItem as DashboardSection); onToggleSection(selectedItem as DashboardSection);
} else { } else {
getLocationSrv().update({ path: selectedItem.url }); getLocationSrv().update({
path: locationUtil.stripBaseFromUrl(selectedItem.url),
});
// Delay closing to prevent current page flicker // Delay closing to prevent current page flicker
setTimeout(onCloseSearch, 0); setTimeout(onCloseSearch, 0);
} }