Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/6.0.0' into jason/freeze-trailin…
Browse files Browse the repository at this point in the history
…g-rows
  • Loading branch information
jassmith committed Jan 5, 2024
2 parents 3a19124 + 4a1d98b commit 995d0c8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/internal/data-grid/data-grid-lib.ts
Expand Up @@ -446,7 +446,7 @@ export function getEmHeight(ctx: CanvasRenderingContext2D, fontStyle: string): n
return textMetrics.actualBoundingBoxAscent + textMetrics.actualBoundingBoxDescent;
}

function truncateString(data: string, w: number) {
function truncateString(data: string, w: number): string {
if (data.includes("\n")) {
// new lines are rare and split is relatively expensive compared to the search
// it pays off to not do the split contantly.
Expand All @@ -456,6 +456,7 @@ function truncateString(data: string, w: number) {
if (data.length > max) {
data = data.slice(0, max);
}
return data;
}

function drawMultiLineText(
Expand Down Expand Up @@ -513,7 +514,7 @@ export function drawTextCell(
allowWrapping = allowWrapping ?? false;

if (!allowWrapping) {
truncateString(data, w);
data = truncateString(data, w);
}

const bias = getMiddleCenterBias(ctx, theme);
Expand Down

0 comments on commit 995d0c8

Please sign in to comment.