Skip to content

Commit

Permalink
feat(console): add escape key press event to clear selected node in t…
Browse files Browse the repository at this point in the history
…he map view (#5804)
  • Loading branch information
skyrpex authored Mar 3, 2024
1 parent b189bf4 commit bc2bc51
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/wing-console/console/ui/src/ui/elk-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -576,6 +577,13 @@ export const ElkMap = <T extends unknown = undefined>({

const mapBackgroundRef = useRef<HTMLDivElement>(null);

useKeyPressEvent(
"Escape",
useCallback(() => {
onSelectedNodeIdChange?.(undefined);
}, [onSelectedNodeIdChange]),
);

return (
<>
<InvisibleNodeSizeCalculator
Expand Down

0 comments on commit bc2bc51

Please sign in to comment.