Fix bug that caused closing the select map modal to select the map

Added ability to deselect a map by clicking outside of the map select tile
This commit is contained in:
Mitchell McCaffrey
2020-08-06 13:31:46 +10:00
parent 4347b5759d
commit 93a09db707
3 changed files with 18 additions and 3 deletions

View File

@@ -184,7 +184,11 @@ function SelectMapModal({
async function handleMapSelect(map) {
await applyMapChanges();
setSelectedMapId(map.id);
if (map) {
setSelectedMapId(map.id);
} else {
setSelectedMapId(null);
}
}
async function handleMapReset(id) {
@@ -195,6 +199,13 @@ function SelectMapModal({
}
}
async function handleClose() {
if (selectedMapId) {
await applyMapChanges();
}
onDone();
}
async function handleDone() {
if (imageLoading) {
return;
@@ -202,6 +213,8 @@ function SelectMapModal({
if (selectedMapId) {
await applyMapChanges();
onMapChange(selectedMapWithChanges, selectedMapStateWithChanges);
} else {
onMapChange(null, null);
}
onDone();
}
@@ -250,7 +263,7 @@ function SelectMapModal({
};
return (
<Modal isOpen={isOpen} onRequestClose={handleDone}>
<Modal isOpen={isOpen} onRequestClose={handleClose}>
<ImageDrop onDrop={handleImagesUpload} dropText="Drop map to upload">
<input
onChange={(event) => handleImagesUpload(event.target.files)}