Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore: Be sure time range key bindings are mounted after clear #61892

Merged
merged 4 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions public/app/core/services/keybindingSrv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import { withFocusedPanel } from './withFocusedPanelId';

export class KeybindingSrv {
constructor(private locationService: LocationService, private chromeService: AppChromeService) {}
bindings: string[] = [];

clearAndInitGlobalBindings() {
Mousetrap.reset();
this.bindings = [];

if (this.locationService.getLocation().pathname !== '/login') {
this.bind(['?', 'h'], this.showHelpModal);
Expand Down Expand Up @@ -164,6 +166,9 @@ export class KeybindingSrv {
}

bind(keyArg: string | string[], fn: () => void) {
const keyArgArr = Array.isArray(keyArg) ? keyArg : [keyArg];
this.bindings.push(...keyArgArr);

Mousetrap.bind(
keyArg,
(evt) => {
Expand All @@ -177,6 +182,8 @@ export class KeybindingSrv {
}

bindGlobal(keyArg: string, fn: () => void) {
this.bindings.push(keyArg);

Mousetrap.bindGlobal(
keyArg,
(evt) => {
Expand All @@ -190,6 +197,7 @@ export class KeybindingSrv {
}

unbind(keyArg: string, keyType?: string) {
this.bindings = this.bindings.filter((binding) => binding !== keyArg);
Mousetrap.unbind(keyArg, keyType);
}

Expand Down
2 changes: 1 addition & 1 deletion public/app/features/explore/ExplorePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function ExplorePage(props: GrafanaRouteComponentProps<{}, ExploreQueryPa

useEffect(() => {
keybindings.setupTimeRangeBindings(false);
}, [keybindings]);
}, [keybindings, keybindings.bindings]);
gelicia marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (!config.featureToggles.correlations) {
Expand Down