mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -06:00
Fixed issue where double clicking on back button closes sidemenu
This commit is contained in:
parent
f38e64cc5d
commit
9565e48f03
@ -8,6 +8,16 @@ jest.mock('../../app_events', () => ({
|
||||
emit: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('app/store/store', () => ({
|
||||
store: {
|
||||
getState: jest.fn().mockReturnValue({
|
||||
location: {
|
||||
lastUpdated: 0,
|
||||
}
|
||||
})
|
||||
}
|
||||
}));
|
||||
|
||||
jest.mock('app/core/services/context_srv', () => ({
|
||||
contextSrv: {
|
||||
sidemenu: true,
|
||||
|
@ -3,9 +3,16 @@ import appEvents from '../../app_events';
|
||||
import { contextSrv } from 'app/core/services/context_srv';
|
||||
import TopSection from './TopSection';
|
||||
import BottomSection from './BottomSection';
|
||||
import { store } from 'app/store/store';
|
||||
|
||||
export class SideMenu extends PureComponent {
|
||||
toggleSideMenu = () => {
|
||||
// ignore if we just made a location change, stops hiding sidemenu on double clicks of back button
|
||||
const timeSinceLocationChanged = new Date().getTime() - store.getState().location.lastUpdated;
|
||||
if (timeSinceLocationChanged < 1000) {
|
||||
return;
|
||||
}
|
||||
|
||||
contextSrv.toggleSideMenu();
|
||||
appEvents.emit('toggle-sidemenu');
|
||||
};
|
||||
|
@ -9,6 +9,7 @@ export const initialState: LocationState = {
|
||||
query: {},
|
||||
routeParams: {},
|
||||
replace: false,
|
||||
lastUpdated: 0,
|
||||
};
|
||||
|
||||
export const locationReducer = (state = initialState, action: Action): LocationState => {
|
||||
@ -28,6 +29,7 @@ export const locationReducer = (state = initialState, action: Action): LocationS
|
||||
query: { ...query },
|
||||
routeParams: routeParams || state.routeParams,
|
||||
replace: replace === true,
|
||||
lastUpdated: new Date().getTime(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import { createLogger } from 'redux-logger';
|
||||
// import { createLogger } from 'redux-logger';
|
||||
import sharedReducers from 'app/core/reducers';
|
||||
import alertingReducers from 'app/features/alerting/state/reducers';
|
||||
import teamsReducers from 'app/features/teams/state/reducers';
|
||||
@ -41,7 +41,7 @@ export function configureStore() {
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// DEV builds we had the logger middleware
|
||||
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk, createLogger()))));
|
||||
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk))));
|
||||
} else {
|
||||
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk))));
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ export interface LocationState {
|
||||
query: UrlQueryMap;
|
||||
routeParams: UrlQueryMap;
|
||||
replace: boolean;
|
||||
lastUpdated: number;
|
||||
}
|
||||
|
||||
export type UrlQueryValue = string | number | boolean | string[] | number[] | boolean[];
|
||||
|
@ -21,9 +21,9 @@
|
||||
// Search
|
||||
.search-field-wrapper {
|
||||
width: 100%;
|
||||
height: $navbarHeight;
|
||||
display: flex;
|
||||
background-color: $navbarBackground;
|
||||
box-shadow: $navbarShadow;
|
||||
position: relative;
|
||||
|
||||
& > input {
|
||||
|
Loading…
Reference in New Issue
Block a user