Added auto switch away from a disabled tool

This commit is contained in:
Mitchell McCaffrey 2020-04-20 15:31:54 +10:00
parent 77df9b6f35
commit 06f5d3ab42

View File

@ -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 = (
<Box
my={2}