From d923f4edb2b62e12149db175eaf0b0d531c63d05 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 24 Jun 2024 14:48:15 +0100 Subject: [PATCH] Fix crash when using up and down arrows in new row --- .../grid/overlays/KeyboardManager.svelte | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/frontend-core/src/components/grid/overlays/KeyboardManager.svelte b/packages/frontend-core/src/components/grid/overlays/KeyboardManager.svelte index 46df56b6ce..27273fb598 100644 --- a/packages/frontend-core/src/components/grid/overlays/KeyboardManager.svelte +++ b/packages/frontend-core/src/components/grid/overlays/KeyboardManager.svelte @@ -2,6 +2,7 @@ import { getContext, onMount } from "svelte" import { debounce } from "../../../utils/utils" import { getCellID, parseCellID } from "../lib/utils" + import { NewRowID } from "../lib/constants" const { rows, @@ -19,6 +20,7 @@ selectedCells, cellSelection, columnLookupMap, + focusedRowId, } = getContext("grid") const ignoredOriginSelectors = [ @@ -69,14 +71,6 @@ // Handle certain key presses if we have cells selected if ($selectedCellCount) { switch (e.key) { - case "ArrowLeft": - return handle(() => changeFocusedColumn(-1, e.shiftKey)) - case "ArrowRight": - return handle(() => changeFocusedColumn(1, e.shiftKey)) - case "ArrowUp": - return handle(() => changeFocusedRow(-1, e.shiftKey)) - case "ArrowDown": - return handle(() => changeFocusedRow(1, e.shiftKey)) case "Escape": return handle(selectedCells.actions.clear) case "Delete": @@ -215,6 +209,11 @@ // Changes the focused cell by moving it up or down to a new row const changeFocusedRow = (delta, shiftKey) => { + // Ignore for new row component + if ($focusedRowId === NewRowID) { + return + } + // Determine which cell we are working with let sourceCellId = $focusedCellId if (shiftKey && $selectedCellCount) {