fix(i18n): handle missing date formats - #17501
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a regression in Ignite UI’s BaseFormatter.formatDate() when running under Angular 22.1+ by preventing Angular’s formatDate() from being called with a missing/empty format string (which can throw due to .length validation added upstream).
Changes:
- Broadened
BaseFormatter.formatDate()’sformatparameter type to allownull | undefinedand added a guard to return''when the format is missing/empty. - Added a regression unit test covering
undefined,null, and''format inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| projects/igniteui-angular/core/src/core/i18n/formatters/formatter-base.ts | Avoids calling Angular formatDate() when format is missing/empty by widening type + adding a guard. |
| projects/igniteui-angular/core/src/core/i18n/formatters/formatter-base.spec.ts | Adds regression coverage for missing/empty format values returning an empty string. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
ivanvpetrov
left a comment
There was a problem hiding this comment.
The tests now pass. Judging by that the fix is ok.
What I'm not sure of, is if this fix changes any behavior in an unwanted way.
@ivanvpetrov, good point. I checked the affected paths. The only runtime change is in Valid formats still go directly through Angular’s Therefore, no behavior should change for valid inputs. The fix only prevents the new Angular 22.1 exception for missing formats. |
Closes #17493
Description
Prevents Angular 22.1 from throwing when a date format is null, undefined, or empty. Preserves the previous empty-string behavior and adds regression coverage.
Motivation / Context
Type of Change (check all that apply):
Component(s) / Area(s) Affected:
How Has This Been Tested?
Test Configuration:
Screenshots / Recordings
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)