From bc2bc51ea7e8167a1720e7959345b21fe16f0351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Pallar=C3=A9s?= Date: Sun, 3 Mar 2024 15:33:49 +0100 Subject: [PATCH] feat(console): add escape key press event to clear selected node in the map view (#5804) --- apps/wing-console/console/ui/src/ui/elk-map.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/wing-console/console/ui/src/ui/elk-map.tsx b/apps/wing-console/console/ui/src/ui/elk-map.tsx index 5b1fb841be8..d32acc3ec6f 100644 --- a/apps/wing-console/console/ui/src/ui/elk-map.tsx +++ b/apps/wing-console/console/ui/src/ui/elk-map.tsx @@ -17,6 +17,7 @@ import { useState, } from "react"; import { createPortal } from "react-dom"; +import { useKeyPressEvent } from "react-use"; import { Edge } from "../shared/Edge.js"; import { Node } from "../shared/Node.js"; @@ -576,6 +577,13 @@ export const ElkMap = ({ const mapBackgroundRef = useRef(null); + useKeyPressEvent( + "Escape", + useCallback(() => { + onSelectedNodeIdChange?.(undefined); + }, [onSelectedNodeIdChange]), + ); + return ( <>