fix undefiend tooltip (#10731)

This commit is contained in:
Eugenio Romano 2025-03-20 16:33:59 +01:00 committed by GitHub
parent 4249a856c9
commit 3475098f32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 1 deletions

View File

@ -1232,4 +1232,28 @@ describe('FormFieldModel', () => {
expect(FormFieldTypes.isValidatableType(FormFieldTypes.TEXT)).toBeFalse(); expect(FormFieldTypes.isValidatableType(FormFieldTypes.TEXT)).toBeFalse();
expect(field.validate()).toBe(true); expect(field.validate()).toBe(true);
}); });
it('should set the tooltip correctly', () => {
const form = new FormModel();
const tooltipText = 'This is a tooltip';
const field = new FormFieldModel(form, {
id: 'field_with_tooltip',
name: 'Field with Tooltip',
type: 'text',
tooltip: tooltipText
});
expect(field.tooltip).toBe(tooltipText);
});
it('should set the tooltip to an empty string when not set', () => {
const form = new FormModel();
const field = new FormFieldModel(form, {
id: 'field_without_tooltip',
name: 'Field without Tooltip',
type: 'text'
});
expect(field.tooltip).toBe('');
});
}); });

View File

@ -211,7 +211,7 @@ export class FormFieldModel extends FormWidgetModel {
this.currency = json.currency; this.currency = json.currency;
this.dateDisplayFormat = json.dateDisplayFormat || this.getDefaultDateFormat(json); this.dateDisplayFormat = json.dateDisplayFormat || this.getDefaultDateFormat(json);
this.validationSummary = new ErrorMessageModel(); this.validationSummary = new ErrorMessageModel();
this.tooltip = json.tooltip; this.tooltip = json.tooltip || '';
this.selectionType = json.selectionType; this.selectionType = json.selectionType;
this.alignmentType = json.alignmentType; this.alignmentType = json.alignmentType;
this.rule = json.rule; this.rule = json.rule;