From 9892227cafc02ef186cfd217125ba54ccc7d9500 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sun, 7 Feb 2021 17:40:22 +1100 Subject: [PATCH] Added fix for grid nudge causing scroll --- src/components/map/MapGridEditor.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/map/MapGridEditor.js b/src/components/map/MapGridEditor.js index a138442..fcca37e 100644 --- a/src/components/map/MapGridEditor.js +++ b/src/components/map/MapGridEditor.js @@ -162,9 +162,12 @@ function MapGridEditor({ map, onGridChange }) { }); } - function handleKeyDown({ key, shiftKey }) { + function handleKeyDown(event) { + const { key, shiftKey } = event; const nudgeAmount = shiftKey ? 2 : 0.5; if (key === "ArrowUp") { + // Stop arrow up/down scrolling if overflowing + event.preventDefault(); nudgeGrid({ x: 0, y: -1 }, nudgeAmount); } if (key === "ArrowLeft") { @@ -174,6 +177,7 @@ function MapGridEditor({ map, onGridChange }) { nudgeGrid({ x: 1, y: 0 }, nudgeAmount); } if (key === "ArrowDown") { + event.preventDefault(); nudgeGrid({ x: 0, y: 1 }, nudgeAmount); } }