mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-38748 Fix ComputeTitle undefined error in upstream (#11334)
* fix: undefined error in computeTitle
This commit is contained in:
@@ -120,4 +120,23 @@ describe('DataTableCellComponent', () => {
|
|||||||
checkDisplayedText('hello worl...');
|
checkDisplayedText('hello worl...');
|
||||||
checkDisplayedTooltip('hello world');
|
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) {
|
if (this.tooltip) {
|
||||||
return this.tooltip;
|
return this.tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawValue = value;
|
const rawValue = value;
|
||||||
const max = this.column?.maxTextLength;
|
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 rawValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user