Skip to content

Commit a19bc11

Browse files
authored
fix: Pass optional expandDescendants arg to setColumnExpanded (#2540)
- Pass optional `expandDescendants` arg to `setColumnExpanded` - Pass mouse handlers and renderer from `IrisGridPanel` to `IrisGrid`
1 parent cbb4fc5 commit a19bc11

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

packages/dashboard-core-plugins/src/panels/IrisGridPanel.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ import {
4545
type ColumnHeaderGroup,
4646
type IrisGridContextMenuData,
4747
type PartitionConfig,
48+
type IrisGridRenderer,
49+
type MouseHandlersProp,
4850
} from '@deephaven/iris-grid';
4951
import {
5052
type RowDataMap,
@@ -153,7 +155,10 @@ export interface OwnProps extends DashboardPanelProps {
153155
/** Load a plugin defined by the table */
154156
loadPlugin: (pluginName: string) => TablePluginComponent;
155157

156-
theme?: IrisGridThemeType;
158+
theme?: Partial<IrisGridThemeType> & Record<string, unknown>;
159+
160+
mouseHandlers?: MouseHandlersProp;
161+
renderer?: IrisGridRenderer;
157162
}
158163

159164
interface StateProps {
@@ -1135,8 +1140,10 @@ export class IrisGridPanel extends PureComponent<
11351140
inputFilters,
11361141
links,
11371142
metadata,
1143+
mouseHandlers,
11381144
panelState,
11391145
user,
1146+
renderer,
11401147
settings,
11411148
theme,
11421149
} = this.props;
@@ -1239,11 +1246,13 @@ export class IrisGridPanel extends PureComponent<
12391246
isSelectingPartition={isSelectingPartition}
12401247
isStuckToBottom={isStuckToBottom}
12411248
isStuckToRight={isStuckToRight}
1249+
mouseHandlers={mouseHandlers}
12421250
movedColumns={movedColumns}
12431251
movedRows={movedRows}
12441252
partitions={partitions}
12451253
partitionConfig={partitionConfig}
12461254
quickFilters={quickFilters}
1255+
renderer={renderer}
12471256
reverse={reverse}
12481257
rollupConfig={rollupConfig}
12491258
settings={settings}

packages/iris-grid/src/IrisGrid.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ export interface IrisGridContextMenuData {
278278
modelColumn: GridRangeIndex;
279279
}
280280

281+
export type MouseHandlersProp = readonly (
282+
| GridMouseHandler
283+
| ((irisGrid: IrisGrid) => GridMouseHandler)
284+
)[];
285+
281286
export interface IrisGridProps {
282287
children: React.ReactNode;
283288
advancedFilters: ReadonlyAdvancedFilterMap;
@@ -361,7 +366,7 @@ export interface IrisGridProps {
361366

362367
// Optional key and mouse handlers
363368
keyHandlers: readonly KeyHandler[];
364-
mouseHandlers: readonly GridMouseHandler[];
369+
mouseHandlers: MouseHandlersProp;
365370

366371
// Pass in a custom renderer to the grid for advanced use cases
367372
renderer?: IrisGridRenderer;
@@ -751,13 +756,15 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
751756
columnHeaderGroups,
752757
} = props;
753758

759+
const { mouseHandlers: mouseHandlersProp } = props;
760+
754761
const { dh } = model;
755762
const keyHandlers: KeyHandler[] = [
756763
new CopyCellKeyHandler(this),
757764
new ReverseKeyHandler(this),
758765
new ClearFilterKeyHandler(this),
759766
];
760-
const mouseHandlers: GridMouseHandler[] = [
767+
const mouseHandlers: MouseHandlersProp = [
761768
new IrisGridCellOverflowMouseHandler(this),
762769
new IrisGridRowTreeMouseHandler(this),
763770
new IrisGridTokenMouseHandler(this),
@@ -769,10 +776,11 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
769776
new IrisGridDataSelectMouseHandler(this),
770777
new PendingMouseHandler(this),
771778
new IrisGridPartitionedTableMouseHandler(this),
779+
...mouseHandlersProp,
780+
...(canCopy ? [new IrisGridCopyCellMouseHandler(this)] : []),
772781
];
773782
if (canCopy) {
774783
keyHandlers.push(new CopyKeyHandler(this));
775-
mouseHandlers.push(new IrisGridCopyCellMouseHandler(this));
776784
}
777785
const movedColumns =
778786
movedColumnsProp.length > 0
@@ -1095,7 +1103,7 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
10951103

10961104
keyHandlers: readonly KeyHandler[];
10971105

1098-
mouseHandlers: readonly GridMouseHandler[];
1106+
mouseHandlers: MouseHandlersProp;
10991107

11001108
get gridWrapper(): HTMLDivElement | null {
11011109
return this.grid?.canvasWrapper.current ?? null;
@@ -1538,9 +1546,10 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
15381546
}
15391547

15401548
getCachedMouseHandlers = memoize(
1541-
(
1542-
mouseHandlers: readonly GridMouseHandler[]
1543-
): readonly GridMouseHandler[] => [...mouseHandlers, ...this.mouseHandlers],
1549+
(mouseHandlers: MouseHandlersProp): readonly GridMouseHandler[] =>
1550+
[...mouseHandlers, ...this.mouseHandlers].map(handler =>
1551+
typeof handler === 'function' ? handler(this) : handler
1552+
),
15441553
{ max: 1 }
15451554
);
15461555

@@ -2586,11 +2595,18 @@ class IrisGrid extends Component<IrisGridProps, IrisGridState> {
25862595
});
25872596
}
25882597

2589-
toggleExpandColumn(modelIndex: ModelIndex): void {
2598+
toggleExpandColumn(
2599+
modelIndex: ModelIndex,
2600+
expandDescendants?: boolean
2601+
): void {
25902602
log.debug2('Toggle expand column', modelIndex);
25912603
const { model } = this.props;
25922604
if (isExpandableColumnGridModel(model) && model.hasExpandableColumns) {
2593-
model.setColumnExpanded(modelIndex, !model.isColumnExpanded(modelIndex));
2605+
model.setColumnExpanded(
2606+
modelIndex,
2607+
!model.isColumnExpanded(modelIndex),
2608+
expandDescendants
2609+
);
25942610
}
25952611
}
25962612

0 commit comments

Comments
 (0)