From 73e1837eb2fdb161779724a8b275f4d8147b95c0 Mon Sep 17 00:00:00 2001 From: Mike Bender Date: Thu, 4 Jan 2024 17:22:08 -0500 Subject: [PATCH] fix: Interface for IrisGridTableModelTemplate.backgroundColorForCell (#1699) - The implementation for IrisGridTableModelTemplate.backgroundColorForCell did not accept a theme, even though GridModel.backgroundColorForCell does - This caused issues with classes that extended IrisGridTableModelTemplate or it's subclasses like IrisGridTableModel, as the could not override this method to correctly accept the theme parameter - Also export all types from GridTheme - there were a few things not being exported (such as `GridColor`) - Fixes #1697 BREAKING CHANGE: - Subclasses of IrisGridTableModelTemplate or it's subclasses that use backgroundColorForCell may need to update their signature to accept the theme if they are calling the superclass --- packages/grid/src/index.ts | 1 + packages/iris-grid/src/IrisGrid.tsx | 4 ++-- packages/iris-grid/src/IrisGridTableModelTemplate.ts | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/grid/src/index.ts b/packages/grid/src/index.ts index d19a66d01b..b0744d032b 100644 --- a/packages/grid/src/index.ts +++ b/packages/grid/src/index.ts @@ -11,6 +11,7 @@ export * from './GridRange'; export * from './GridAxisRange'; export * from './GridRenderer'; export { default as GridTestUtils } from './GridTestUtils'; +export * from './GridTheme'; export { default as GridTheme } from './GridTheme'; export type { GridTheme as GridThemeType } from './GridTheme'; export * from './GridUtils'; diff --git a/packages/iris-grid/src/IrisGrid.tsx b/packages/iris-grid/src/IrisGrid.tsx index d66b0c92e1..3d387c75d2 100644 --- a/packages/iris-grid/src/IrisGrid.tsx +++ b/packages/iris-grid/src/IrisGrid.tsx @@ -1372,8 +1372,8 @@ export class IrisGrid extends Component { getCachedTheme = memoize( ( - contextTheme: GridThemeType | null, - theme: GridThemeType | null, + contextTheme: Partial | null, + theme: Partial | null, isEditable: boolean, floatingRowCount: number ): Partial => { diff --git a/packages/iris-grid/src/IrisGridTableModelTemplate.ts b/packages/iris-grid/src/IrisGridTableModelTemplate.ts index 74e8a7b5a2..2b64e196bf 100644 --- a/packages/iris-grid/src/IrisGridTableModelTemplate.ts +++ b/packages/iris-grid/src/IrisGridTableModelTemplate.ts @@ -625,7 +625,11 @@ class IrisGridTableModelTemplate< return theme.textColor; } - backgroundColorForCell(x: ModelIndex, y: ModelIndex): string | null { + backgroundColorForCell( + x: ModelIndex, + y: ModelIndex, + theme: IrisGridThemeType + ): string | null { return this.formatForCell(x, y)?.backgroundColor ?? null; }