Skip to content

fix(i18n): handle missing date formats - #17501

Open
viktorkombov wants to merge 1 commit into
masterfrom
vkombov/bug-17493
Open

fix(i18n): handle missing date formats#17501
viktorkombov wants to merge 1 commit into
masterfrom
vkombov/bug-17493

Conversation

@viktorkombov

@viktorkombov viktorkombov commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version:
  • Browser(s):
  • OS:

Screenshots / Recordings

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()’s format parameter type to allow null | undefined and 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.

Comment on lines +80 to +81
public formatDate(value: Date | string | number | null | undefined, format: string | null | undefined, locale: string, timezone?: string): string {
return value != null && format ? ngFormatDate(value, format, locale, timezone) : '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IgxDateFormatterPipe throws TypeError: Cannot read properties of undefined (reading 'length') when format is undefined after Angular 22.1 upgrade

3 participants