From 3e7626cc96c91af4b168514a778f4fbab5b3281d Mon Sep 17 00:00:00 2001 From: Victor Marin <36818606+mdvictor@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:40:37 +0200 Subject: [PATCH] Dashboards: Fix missing `v/e/i` keybindings to return back to dashboard (#101876) readd keybindings to return from edit/view/inspect modes --- .../scene/keyboardShortcuts.ts | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/public/app/features/dashboard-scene/scene/keyboardShortcuts.ts b/public/app/features/dashboard-scene/scene/keyboardShortcuts.ts index 3a4bd4687f0..cde032a413e 100644 --- a/public/app/features/dashboard-scene/scene/keyboardShortcuts.ts +++ b/public/app/features/dashboard-scene/scene/keyboardShortcuts.ts @@ -43,7 +43,13 @@ export function setupKeyboardShortcuts(scene: DashboardScene) { keybindings.addBinding({ key: 'v', onTrigger: withFocusedPanel(scene, (vizPanel: VizPanel) => { - if (!scene.state.viewPanelScene) { + if (scene.state.viewPanelScene) { + locationService.push( + locationUtil.getUrlForPartial(locationService.getLocation(), { + viewPanel: undefined, + }) + ); + } else { const url = locationUtil.stripBaseFromUrl(getViewPanelUrl(vizPanel)); locationService.push(url); } @@ -105,7 +111,15 @@ export function setupKeyboardShortcuts(scene: DashboardScene) { keybindings.addBinding({ key: 'i', onTrigger: withFocusedPanel(scene, async (vizPanel: VizPanel) => { - locationService.push(locationUtil.stripBaseFromUrl(getInspectUrl(vizPanel))); + if (scene.state.inspectPanelKey) { + locationService.push( + locationUtil.getUrlForPartial(locationService.getLocation(), { + inspect: undefined, + }) + ); + } else { + locationService.push(locationUtil.stripBaseFromUrl(getInspectUrl(vizPanel))); + } }), }); @@ -178,7 +192,13 @@ export function setupKeyboardShortcuts(scene: DashboardScene) { const sceneRoot = vizPanel.getRoot(); if (sceneRoot instanceof DashboardScene) { const panelId = getPanelIdForVizPanel(vizPanel); - if (!scene.state.editPanel) { + if (scene.state.editPanel) { + locationService.push( + locationUtil.getUrlForPartial(locationService.getLocation(), { + editPanel: undefined, + }) + ); + } else { const url = locationUtil.stripBaseFromUrl(getEditPanelUrl(panelId)); locationService.push(url); }