AAE-38748 Fix ComputeTitle undefined error in upstream (#11334)

* fix: undefined error in computeTitle
This commit is contained in:
Joshua Cain
2025-11-07 07:40:15 -05:00
committed by GitHub
parent 61e1395bfa
commit e11aa6ddf3
2 changed files with 20 additions and 3 deletions
@@ -120,4 +120,23 @@ describe('DataTableCellComponent', () => {
checkDisplayedText('hello worl...');
checkDisplayedTooltip('hello world');
});
it('should compute empty title when column value is undefined', () => {
const row: DataRow = {
id: '1',
isSelected: false,
hasValue: () => false,
getValue: () => undefined,
obj: 'Initial Value',
cache: []
};
component.data = new ObjectDataTableAdapter();
component.column = { key: 'car_name', type: 'text', maxTextLength: 10 };
component.row = row;
expect(() => fixture.detectChanges()).not.toThrow();
expect(component.computedTitle).toBe('');
expect(testingUtils.getByCSS('span').nativeElement.title).toBe('');
});
});
@@ -117,14 +117,12 @@ export class DataTableCellComponent implements OnInit {
if (this.tooltip) {
return this.tooltip;
}
const rawValue = value;
const max = this.column?.maxTextLength;
if (typeof max === 'number' && max > 0 && rawValue.length > max) {
if (typeof max === 'number' && max > 0 && rawValue?.length > max) {
return rawValue;
}
return '';
}
}