Fix selectMapButton name and a bug with deleting a map that isn't the current one

This commit is contained in:
Mitchell McCaffrey
2020-04-23 21:54:58 +10:00
parent 81da404eec
commit 5539fcf16a
5 changed files with 63 additions and 27 deletions

View File

@@ -22,6 +22,7 @@ function Map({
onMapTokenChange,
onMapTokenRemove,
onMapChange,
onMapStateChange,
onMapDraw,
onMapDrawUndo,
onMapDrawRedo,
@@ -296,6 +297,8 @@ function Map({
</Box>
<MapControls
onMapChange={onMapChange}
onMapStateChange={onMapStateChange}
currentMap={map}
onToolChange={setSelectedTool}
selectedTool={selectedTool}
disabledTools={disabledTools}

View File

@@ -1,7 +1,7 @@
import React, { useState, useEffect, useRef } from "react";
import { Flex, Box, IconButton, Label } from "theme-ui";
import SelectMapButton from "./SelectMapIcon";
import SelectMapButton from "./SelectMapButton";
import ExpandMoreIcon from "../../icons/ExpandMoreIcon";
import PanToolIcon from "../../icons/PanToolIcon";
import BrushToolIcon from "../../icons/BrushToolIcon";
@@ -22,6 +22,8 @@ import EraseAllIcon from "../../icons/EraseAllIcon";
function MapControls({
onMapChange,
onMapStateChange,
currentMap,
onToolChange,
selectedTool,
disabledTools,
@@ -233,7 +235,11 @@ function MapControls({
p={2}
ref={expanedMenuRef}
>
<SelectMapButton onMapChange={onMapChange} />
<SelectMapButton
onMapChange={onMapChange}
onMapStateChange={onMapStateChange}
currentMap={currentMap}
/>
{divider}
<IconButton
aria-label="Pan Tool"

View File

@@ -4,7 +4,7 @@ import { IconButton } from "theme-ui";
import SelectMapModal from "../../modals/SelectMapModal";
import SelectMapIcon from "../../icons/SelectMapIcon";
function SelectMapButton({ onMapChange }) {
function SelectMapButton({ onMapChange, onMapStateChange, currentMap }) {
const [isAddModalOpen, setIsAddModalOpen] = useState(false);
function openModal() {
setIsAddModalOpen(true);
@@ -13,10 +13,7 @@ function SelectMapButton({ onMapChange }) {
setIsAddModalOpen(false);
}
function handleDone(map, mapState) {
if (map) {
onMapChange(map, mapState);
}
function handleDone() {
closeModal();
}
@@ -33,6 +30,9 @@ function SelectMapButton({ onMapChange }) {
isOpen={isAddModalOpen}
onRequestClose={closeModal}
onDone={handleDone}
onMapChange={onMapChange}
onMapStateChange={onMapStateChange}
currentMap={currentMap}
/>
</>
);