From c73fb2a321cc761a674d4fc73b108b0da521b3ef Mon Sep 17 00:00:00 2001 From: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> Date: Thu, 2 Nov 2023 15:24:54 -0400 Subject: [PATCH] fix(html/common): correct BreakdownTable tooltip height calculation Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> --- packages/common/src/Utility.ts | 5 ++++- packages/html/src/BreakdownTable.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/common/src/Utility.ts b/packages/common/src/Utility.ts index b0f41af31a..459972219d 100644 --- a/packages/common/src/Utility.ts +++ b/packages/common/src/Utility.ts @@ -739,7 +739,10 @@ export function textSize(_text: string | string[], fontName: string = "Verdana", g_fontSizeContext.font = `${bold ? "bold " : ""}${fontSize}px ${fontName}`; g_fontSizeContextCache[hash] = retVal = { width: Math.max(...text.map(t => g_fontSizeContext.measureText("" + t).width)), - height: fontSize * text.length + height: Math.max(...text.map(t => { + const textMeasurement = g_fontSizeContext.measureText("" + t); + return textMeasurement.fontBoundingBoxDescent + textMeasurement.fontBoundingBoxAscent; + })) }; } return retVal; diff --git a/packages/html/src/BreakdownTable.ts b/packages/html/src/BreakdownTable.ts index 9055793050..73f27851db 100644 --- a/packages/html/src/BreakdownTable.ts +++ b/packages/html/src/BreakdownTable.ts @@ -53,8 +53,8 @@ export class BreakdownTable extends StyledTable { this._tooltip .tooltipHTML(data => { const rowCount = this.useCalculatedRowCount() ? this.calculateRowCount() : this.rowCount(); - const rowHeight = this.fontSize(); - const widestLabel = Math.max(...data.map(row => this.textSize(row[0], "Verdana", this.fontSize()).width)); + const rowHeight = Math.max(...data.map(row => this.textSize(row[0], this.fontFamily(), this.fontSize()).height)) ?? this.fontSize(); + const widestLabel = Math.max(...data.map(row => this.textSize(row[0], this.fontFamily(), this.fontSize()).width)); const widestPerc = 30; const colCount = 2; const w = colCount * (widestLabel + widestPerc) + (this._tooltip.padding() * 2); @@ -65,13 +65,13 @@ export class BreakdownTable extends StyledTable { return `