From 871c442fc3e8933707180b1405d33419eaae707c Mon Sep 17 00:00:00 2001 From: Jens Martin Norheim Berget Date: Wed, 3 Jan 2024 16:00:33 +0100 Subject: [PATCH 1/2] fix: :bug: Fix bug with clicking tiles to toggle them Fix bug with clicking tiles to toggle them by moving an else-statement in the handleTileClick-const in MapGrid.tsx --- frontend/src/components/mapGrid/MapGrid.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/mapGrid/MapGrid.tsx b/frontend/src/components/mapGrid/MapGrid.tsx index a87a6c0..9f28cb8 100644 --- a/frontend/src/components/mapGrid/MapGrid.tsx +++ b/frontend/src/components/mapGrid/MapGrid.tsx @@ -52,18 +52,20 @@ const MapGrid = () => { // Handle clicking a tile to toggle it const handleTileClick = (row: number, col: number) => { + console.log("selectionModeSignal.value = ", selectionModeSignal.value); if (selectionModeSignal.value) { if (!startPoint) { setStartPoint(`${row}-${col}`); } else if (!endPoint) { setEndPoint(`${row}-${col}`); selectionModeSignal.value = false; - } else { - setActiveTiles((prev) => ({ - ...prev, - [`${row}-${col}`]: !prev[`${row}-${col}`], - })); } + } else { + console.log("Er her"); + setActiveTiles((prev) => ({ + ...prev, + [`${row}-${col}`]: !prev[`${row}-${col}`], + })); } }; From f0654f0e4e3c692b051eec951a2e320701395530 Mon Sep 17 00:00:00 2001 From: Jens Martin Norheim Berget Date: Wed, 3 Jan 2024 16:00:33 +0100 Subject: [PATCH 2/2] fix: :bug: Fix bug with clicking tiles to toggle them Fix bug with clicking tiles to toggle them by moving an else-statement in the handleTileClick-const in MapGrid.tsx --- frontend/src/components/mapGrid/MapGrid.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/mapGrid/MapGrid.tsx b/frontend/src/components/mapGrid/MapGrid.tsx index 382d558..837f7a7 100644 --- a/frontend/src/components/mapGrid/MapGrid.tsx +++ b/frontend/src/components/mapGrid/MapGrid.tsx @@ -52,18 +52,20 @@ const MapGrid = () => { // Handle clicking a tile to toggle it const handleTileClick = (row: number, col: number) => { + console.log("selectionModeSignal.value = ", selectionModeSignal.value); if (selectionModeSignal.value) { if (!startPoint) { setStartPoint(`${row}-${col}`); } else if (!endPoint) { setEndPoint(`${row}-${col}`); selectionModeSignal.value = false; - } else { - setActiveTiles((prev) => ({ - ...prev, - [`${row}-${col}`]: !prev[`${row}-${col}`], - })); } + } else { + console.log("Er her"); + setActiveTiles((prev) => ({ + ...prev, + [`${row}-${col}`]: !prev[`${row}-${col}`], + })); } };