From b3fc7f9e1d27fcce085156086a3aa7fc94d3de9c Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 23 Jul 2021 15:43:32 +1000 Subject: [PATCH] Clear selection when changing maps --- src/hooks/useMapSelection.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hooks/useMapSelection.tsx b/src/hooks/useMapSelection.tsx index 6e7de10..ae9c9fe 100644 --- a/src/hooks/useMapSelection.tsx +++ b/src/hooks/useMapSelection.tsx @@ -32,6 +32,7 @@ function useMapSelection( const active = selectedToolId === "select"; + // Remove selection when changing tools useEffect(() => { if (!active) { setSelection(null); @@ -39,6 +40,12 @@ function useMapSelection( } }, [active]); + // Remove selection when changing maps + useEffect(() => { + setSelection(null); + setIsSelectionMenuOpen(false); + }, [map]); + function handleSelectionDragStart() { setIsSelectionDragging(true); }