Skip to content

Commit c1dccc0

Browse files
committed
Adjust minimum column width for filter box when filters are shown
1 parent 46423d1 commit c1dccc0

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

plugins/pivot/src/js/src/IrisGridPivotMetricCalculator.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class IrisGridPivotMetricCalculator extends IrisGridMetricCalculator {
145145
let result = 0;
146146
keyColumnGroups.forEach(group => {
147147
const sourceIndex = -group.depth;
148-
const width = this.getColumnHeaderGroupTextWidth(
148+
const width = this.getColumnHeaderGroupWidth(
149149
sourceIndex,
150150
0,
151151
state,
@@ -157,33 +157,36 @@ class IrisGridPivotMetricCalculator extends IrisGridMetricCalculator {
157157
}
158158
);
159159

160-
// Gets the text width for a column header group, including padding
161-
getColumnHeaderGroupTextWidth(
162-
modelColumn: ModelIndex,
163-
depth: number,
164-
state: IrisGridPivotMetricState,
165-
maxColumnWidth: number
166-
): number {
167-
return super.getColumnHeaderGroupWidth(
168-
modelColumn,
169-
depth,
170-
state,
171-
maxColumnWidth
172-
);
173-
}
174-
175160
getColumnHeaderGroupWidth(
176161
modelColumn: ModelIndex,
177162
depth: number,
178163
state: IrisGridPivotMetricState,
179164
maxColumnWidth: number
180165
): number {
181-
return this.getColumnHeaderGroupTextWidth(
166+
const baseWidth = super.getColumnHeaderGroupWidth(
182167
modelColumn,
183168
depth,
184169
state,
185170
maxColumnWidth
186171
);
172+
173+
// If modelColumn and depth correspond to a key column group,
174+
// and the filter bar is visible, add space for the filter box
175+
const { isFilterBarShown, model } = state;
176+
177+
if (!isFilterBarShown) {
178+
return baseWidth;
179+
}
180+
181+
const group = model.getColumnHeaderGroup(modelColumn, depth);
182+
if (!isPivotColumnHeaderGroup(group) || !group.isKeyColumnGroup) {
183+
return baseWidth;
184+
}
185+
186+
const { theme } = state;
187+
const { columnSourceFilterMinWidth } = theme;
188+
189+
return baseWidth + columnSourceFilterMinWidth;
187190
}
188191

189192
/**

0 commit comments

Comments
 (0)