Skip to content

Commit 9598d8e

Browse files
authored
Merge pull request #1237 from scottsut/fix
refactor: not render context menu when drillable fields < 2
2 parents f9d5d6b + 5946942 commit 9598d8e

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

frontend/src/app/components/ChartDrill/ChartDrillContextMenu.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,23 @@ const ChartDrillContextMenu: FC<{ chartConfig?: ChartConfig }> = memo(
182182
availableSourceFunctions,
183183
]);
184184

185+
const hasContextMenu =
186+
drillOption?.isDrillable || runtimeDateLevelFields?.length;
187+
185188
return (
186189
<StyledChartDrill className="chart-drill-menu-container">
187-
<Dropdown
188-
disabled={!drillOption}
189-
overlay={contextMenu}
190-
destroyPopupOnHide={true}
191-
trigger={['contextMenu']}
192-
>
190+
{hasContextMenu ? (
191+
<Dropdown
192+
disabled={!drillOption}
193+
overlay={contextMenu}
194+
destroyPopupOnHide={true}
195+
trigger={['contextMenu']}
196+
>
197+
<div style={{ height: '100%' }}>{children}</div>
198+
</Dropdown>
199+
) : (
193200
<div style={{ height: '100%' }}>{children}</div>
194-
</Dropdown>
201+
)}
195202
</StyledChartDrill>
196203
);
197204
},

frontend/src/app/models/ChartDrillOption.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export class ChartDrillOption implements IChartDrillOption {
6363
return this.cursor + 2 === this.drillFields.length;
6464
}
6565

66+
public get isDrillable() {
67+
return this.drillFields.length > 1;
68+
}
69+
6670
public get canSelect() {
6771
return isEmptyArray(this.expandDownFields);
6872
}

frontend/src/app/types/ChartDrillOption.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface IChartDrillOption {
2222
mode: DrillMode;
2323
isSelectedDrill: boolean;
2424
isBottomLevel: boolean;
25+
isDrillable: boolean;
2526
canSelect: boolean;
2627
toggleSelectedDrill(enable?: boolean): void;
2728
getAllFields(): ChartDataSectionField[];

0 commit comments

Comments
 (0)