Skip to content

Commit

Permalink
fix: Interface for IrisGridTableModelTemplate.backgroundColorForCell (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
mofojed authored Jan 4, 2024
1 parent bff6bf9 commit 73e1837
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/grid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/iris-grid/src/IrisGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1372,8 +1372,8 @@ export class IrisGrid extends Component<IrisGridProps, IrisGridState> {

getCachedTheme = memoize(
(
contextTheme: GridThemeType | null,
theme: GridThemeType | null,
contextTheme: Partial<GridThemeType> | null,
theme: Partial<GridThemeType> | null,
isEditable: boolean,
floatingRowCount: number
): Partial<IrisGridThemeType> => {
Expand Down
6 changes: 5 additions & 1 deletion packages/iris-grid/src/IrisGridTableModelTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 73e1837

Please sign in to comment.