Fix no interaction bug when closing token menu with enter

This commit is contained in:
Mitchell McCaffrey 2020-05-21 20:58:17 +10:00
parent b9968053b7
commit 9ace933d30

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState, useContext } from "react";
import { Box, Input, Slider, Flex, Text } from "theme-ui"; import { Box, Input, Slider, Flex, Text } from "theme-ui";
import MapMenu from "../map/MapMenu"; import MapMenu from "../map/MapMenu";
@ -7,6 +7,8 @@ import colors, { colorOptions } from "../../helpers/colors";
import usePrevious from "../../helpers/usePrevious"; import usePrevious from "../../helpers/usePrevious";
import MapInteractionContext from "../../contexts/MapInteractionContext";
const defaultTokenMaxSize = 6; const defaultTokenMaxSize = 6;
/** /**
@ -97,6 +99,8 @@ function TokenMenu({
} }
} }
const { setPreventMapInteraction } = useContext(MapInteractionContext);
return ( return (
<MapMenu <MapMenu
isOpen={isOpen} isOpen={isOpen}
@ -110,6 +114,7 @@ function TokenMenu({
as="form" as="form"
onSubmit={(e) => { onSubmit={(e) => {
e.preventDefault(); e.preventDefault();
setPreventMapInteraction(false);
onRequestClose(); onRequestClose();
}} }}
sx={{ alignItems: "center" }} sx={{ alignItems: "center" }}