diff --git a/src/components/MapControls.js b/src/components/MapControls.js index d6c2a07..c980384 100644 --- a/src/components/MapControls.js +++ b/src/components/MapControls.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { Flex, Box, IconButton, Label } from "theme-ui"; import AddMapButton from "./AddMapButton"; @@ -145,6 +145,13 @@ function MapControls({ } } + // Detect when a tool becomes disabled and switch to to the pan tool + useEffect(() => { + if (disabledTools.includes(selectedTool)) { + onToolChange("pan"); + } + }, [selectedTool, disabledTools, onToolChange]); + const divider = (