Skip to content

Commit

Permalink
fix(common): don't try to strip tags on object input to calc cell wid…
Browse files Browse the repository at this point in the history
…th (#1453)

- when calculating cell content width, we parse the cell data to its Formatter if it exists but if it doesn't then in some cases it could return the entire dataContext and that would then throw when passed to `stripTags()` method, for these cases we can simply assume that the cell width is not calculable since the cell data is not a primitive result (not text, boolean,, number nor HTML)
  • Loading branch information
ghiscoding committed Apr 4, 2024
1 parent 526f5d5 commit 5ab671b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/common/src/services/resizer.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BindingEventService } from '@slickgrid-universal/binding';
import type { BasePubSubService, EventSubscription } from '@slickgrid-universal/event-pub-sub';
import { getInnerSize, getOffset, stripTags } from '@slickgrid-universal/utils';
import { getInnerSize, getOffset, isPrimitiveOrHTML, stripTags } from '@slickgrid-universal/utils';

import { FieldType, } from '../enums/index';
import type {
Expand Down Expand Up @@ -505,7 +505,7 @@ export class ResizerService {
if (!columnDef.originalWidth) {
const charWidthPx = columnDef?.resizeCharWidthInPx ?? resizeCellCharWidthInPx;
const formattedData = parseFormatterWhenExist(columnDef?.formatter, rowIdx, colIdx, columnDef, item, this._grid);
const formattedDataSanitized = stripTags(formattedData);
const formattedDataSanitized = isPrimitiveOrHTML(formattedData) ? stripTags(formattedData) : '';
const formattedTextWidthInPx = Math.ceil(formattedDataSanitized.length * charWidthPx);
const resizeMaxWidthThreshold = columnDef.resizeMaxWidthThreshold;
if (columnDef && (initialMininalColumnWidth === undefined || formattedTextWidthInPx > initialMininalColumnWidth)) {
Expand Down

0 comments on commit 5ab671b

Please sign in to comment.