From 0f3decd127f3b20bbad6e85f4e0db2a6ace5d4ff Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 20 Jun 2024 13:12:59 +0100 Subject: [PATCH] Prevent unnecessary store updates --- .../src/components/grid/stores/pagination.js | 2 +- .../frontend-core/src/components/grid/stores/rows.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/pagination.js b/packages/frontend-core/src/components/grid/stores/pagination.js index f4fdee2ff4..bcf10ee3df 100644 --- a/packages/frontend-core/src/components/grid/stores/pagination.js +++ b/packages/frontend-core/src/components/grid/stores/pagination.js @@ -1,4 +1,4 @@ -import { derived, get } from "svelte/store" +import { derived } from "svelte/store" export const initialise = context => { const { scrolledRowCount, rows, visualRowCapacity } = context diff --git a/packages/frontend-core/src/components/grid/stores/rows.js b/packages/frontend-core/src/components/grid/stores/rows.js index d354dfd9b3..e4b69819ac 100644 --- a/packages/frontend-core/src/components/grid/stores/rows.js +++ b/packages/frontend-core/src/components/grid/stores/rows.js @@ -569,10 +569,12 @@ export const initialise = context => { // Wipe the row change cache when changing row previousFocusedRowId.subscribe(id => { if (id && !get(inProgressChanges)[id]) { - rowChangeCache.update(state => { - delete state[id] - return state - }) + if (Object.keys(get(rowChangeCache)[id] || {}).length) { + rowChangeCache.update(state => { + delete state[id] + return state + }) + } } })