From 60f8ce26af9f476337153b4b0d071c30ec4952b4 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 9 May 2024 16:18:43 +0100 Subject: [PATCH 1/8] Fixing an issue with ID/Rev not being copyable from context menu due to the way IDs were split/handled in the grid. --- .../src/components/grid/stores/ui.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/ui.js b/packages/frontend-core/src/components/grid/stores/ui.js index 928f93f3e1..b75b9aeb0f 100644 --- a/packages/frontend-core/src/components/grid/stores/ui.js +++ b/packages/frontend-core/src/components/grid/stores/ui.js @@ -8,6 +8,15 @@ import { NewRowID, } from "../lib/constants" +function splitRowId(rowId) { + if (!rowId) { + return undefined + } + const parts = rowId.split("-") + const field = parts.pop() + return { id: parts.join("-"), field } +} + export const createStores = context => { const { props } = context const focusedCellId = writable(null) @@ -25,7 +34,7 @@ export const createStores = context => { const focusedRowId = derived( focusedCellId, $focusedCellId => { - return $focusedCellId?.split("-")[0] + return splitRowId($focusedCellId)?.id }, null ) @@ -72,7 +81,7 @@ export const deriveStores = context => { const focusedRow = derived( [focusedCellId, rowLookupMap, rows], ([$focusedCellId, $rowLookupMap, $rows]) => { - const rowId = $focusedCellId?.split("-")[0] + const rowId = splitRowId($focusedCellId)?.id // Edge case for new rows if (rowId === NewRowID) { @@ -152,7 +161,7 @@ export const initialise = context => { const hasRow = rows.actions.hasRow // Check selected cell - const selectedRowId = $focusedCellId?.split("-")[0] + const selectedRowId = splitRowId($focusedCellId)?.id if (selectedRowId && !hasRow(selectedRowId)) { focusedCellId.set(null) } From 076c7db3510fb727462a87c7e9a4fb184a75cbf6 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 9 May 2024 16:55:04 +0100 Subject: [PATCH 2/8] Updating everywhere that the combination was done, to make sure it all goes through one location, using a new character to join/split. --- .../src/components/grid/layout/GridRow.svelte | 3 ++- .../src/components/grid/layout/NewRow.svelte | 7 ++++--- .../components/grid/layout/StickyColumn.svelte | 3 ++- .../src/components/grid/lib/utils.js | 15 +++++++++++++++ .../grid/overlays/KeyboardManager.svelte | 12 ++++++------ .../components/grid/overlays/MenuOverlay.svelte | 3 ++- .../src/components/grid/stores/rows.js | 14 ++++++++------ .../src/components/grid/stores/scroll.js | 3 ++- .../src/components/grid/stores/ui.js | 10 +--------- .../src/components/grid/stores/validation.js | 7 ++++--- 10 files changed, 46 insertions(+), 31 deletions(-) diff --git a/packages/frontend-core/src/components/grid/layout/GridRow.svelte b/packages/frontend-core/src/components/grid/layout/GridRow.svelte index d6c8c3d87b..0b1b4195b2 100644 --- a/packages/frontend-core/src/components/grid/layout/GridRow.svelte +++ b/packages/frontend-core/src/components/grid/layout/GridRow.svelte @@ -1,6 +1,7 @@