Skip to content

fix(pivot-grid): fix pivot grid localization#17246

Open
Hristo313 with Copilot wants to merge 31 commits into
masterfrom
copilot/fix-pivot-grid-date-localization
Open

fix(pivot-grid): fix pivot grid localization#17246
Hristo313 with Copilot wants to merge 31 commits into
masterfrom
copilot/fix-pivot-grid-date-localization

Conversation

Copilot AI commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Adds a display-only headerFormatter hook to IPivotDimension and uses it to localize the leaf-level fullDate values produced by IgxPivotDateDimension, so both row and column dimension headers show locale-aware short dates instead of raw ISO strings. Also fixes date dimension headers being one cycle behind after a locale change.

Changes Made

  • IPivotDimension.headerFormatter — new optional callback (value: any, dimension?, rowData?) => string | null | undefined for display-only dimension header formatting; returning null/undefined falls back to the raw value. Annotated with csTreatAsEvent + blazorOnlyScript for Blazor/C# interop consistency.
  • IgxPivotDateDimension — attaches a locale-aware { dateStyle: 'short' } formatter to the fullDate leaf dimension when no custom memberFunction is provided. All date dimension levels (Months, Quarters, Years, fullDate) now use a consistent recordValue != null && recordValue !== '' guard instead of truthy checks, so epoch-0 timestamps are handled correctly.
  • pivot-row-dimension-content.component.ts — applies dim.headerFormatter(rawHeader) ?? rawHeader when building row dimension header columns.
  • pivot-grid.component.ts — applies dim.headerFormatter(rawHeader) ?? rawHeader in createColumnForDimension so column dimension headers are also formatted. Raw header extraction uses parent.field instead of parent.header for stable value extraction regardless of whether a parent column has a formatter. Fixed the onResourceChangeHandle callback to use notifyDimensionChange(true) instead of setupColumns(), which additionally increments pipeTrigger and calls cdr.detectChanges() synchronously so dimension headers update immediately when the locale changes (the callback fires outside Angular's zone, making markForCheck() alone insufficient).
  • pivot-grid.spec.ts — updated leaf date header assertion to use Intl.DateTimeFormat locale-aware output and replaced ambiguous new Date('12/08/2021') with unambiguous new Date(2021, 11, 8).
  • CHANGELOG.md — added entry documenting the new IPivotDimension.headerFormatter property and the locale update fix.

Notes

  • headerFormatter applies consistently to both row and column dimension header text; returning null/undefined falls back to the raw value.
  • Dimension headers now update immediately on locale change without requiring a manual detectChanges() call.
  • TypeScript compilation passes cleanly with no type errors.

Copilot AI and others added 3 commits April 29, 2026 11:22
…format

When IgxPivotDateDimension is used with fullDate enabled and no
custom memberFunction, attach a locale-aware formatter that formats
leaf-level date values using {dateStyle: 'short'} via Intl.DateTimeFormat.
The formatter is added to a new optional IPivotDimension.formatter
property and applied in the row dimension rendering layer only,
so data keys, sorting, and filtering are unaffected.

Agent-Logs-Url: https://github.com/IgniteUI/igniteui-angular/sessions/0e38c414-30cb-4920-a7ea-3bc9882a866b

Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix pivot grid date dimension values not localized feat(pivot-grid): localize fullDate dimension values in IgxPivotDateDimension Apr 29, 2026
Copilot AI requested a review from Hristo313 April 29, 2026 11:25
@Hristo313

Copy link
Copy Markdown
Contributor

@copilot Fix the failing tests

Copilot AI commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Fix the failing tests

The failing test is unrelated to this PR's changes. The failure is in for_of.directive.spec.ts:313:

1) should always fill available space for last chunk size calculation - vertical virtualization
   IgxForOf directive - vertical virtual component
   Expected 10 to equal 9.

This is a timing-sensitive virtual scrolling test in the IgxForOf directive. Our PR's commits only touched:

  • pivot-grid-dimensions.ts
  • pivot-grid.interface.ts
  • pivot-row-dimension-content.component.ts
  • pivot-grid.spec.ts

None of those files are in the directives/ folder and git diff against the base commit confirms zero overlap. All pivot grid tests pass in the CI run.

@Hristo313 Hristo313 added 🛠️ status: in-development Issues and PRs with active development on them version: 22.0.x grid: pivot labels Apr 29, 2026
@Hristo313
Hristo313 marked this pull request as ready for review April 29, 2026 14:28
Copilot AI review requested due to automatic review settings April 29, 2026 14:28

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

This PR adds a display-only formatting hook for pivot dimensions and uses it to localize leaf-level fullDate values produced by IgxPivotDateDimension, so row headers show locale-aware short dates instead of raw ISO strings.

Changes:

  • Added optional formatter to IPivotDimension for display-only header formatting.
  • Wrapped the fullDate leaf dimension in IgxPivotDateDimension with a locale-aware short-date formatter (when no custom memberFunction is provided).
  • Applied dim.formatter when extracting row dimension header text and updated a related spec assertion to be locale-independent.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
projects/igniteui-angular/grids/pivot-grid/src/pivot-row-dimension-content.component.ts Applies IPivotDimension.formatter to row header text before creating the header column.
projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts Updates expected leaf date header assertion to use Intl.DateTimeFormat output.
projects/igniteui-angular/grids/core/src/pivot-grid.interface.ts Introduces formatter?: (value) => ... to IPivotDimension with docs.
projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts Adds default localized formatter for fullDate leaf dimension when no custom memberFunction exists.

Comment thread projects/igniteui-angular/grids/core/src/pivot-grid.interface.ts Outdated
Comment thread projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts Outdated
Comment thread projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts Outdated
@Hristo313

Copy link
Copy Markdown
Contributor

@copilot Fix the comments

Copilot AI and others added 2 commits April 30, 2026 08:19

Copilot AI commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Fix the comments

All four review comments addressed in commits 6e07821 and 859a146:

  1. IPivotDimension.formatter type → changed from (value: any) => any to (value: any) => string
  2. Falsy check in formatter → replaced value ? with value !== null && value !== undefined && value !== '' so epoch-0 timestamps still get formatted
  3. Formatter coercion in extractFromDimension → simplified to dim.formatter(rawHeader) ?? rawHeader (nullish coalescing, since return type is now string)
  4. Ambiguous date in spec → replaced new Date('12/08/2021') with new Date(2021, 11, 8)

@Hristo313 Hristo313 added 💥 status: in-test PRs currently being tested and removed 🛠️ status: in-development Issues and PRs with active development on them labels Apr 30, 2026
Copilot AI review requested due to automatic review settings July 24, 2026 13:24

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts Outdated
Comment thread projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts
Comment thread projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 13:31

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts:112

  • IgxPivotDateDimension declares public locale?: string; twice (lines 110 and 118), which will fail TypeScript compilation with a duplicate identifier/property error. Keep a single locale property (with the new JSDoc) and remove the duplicate.
    public locale?: string;
    public displayName: string;
    /**

Copilot AI review requested due to automatic review settings July 24, 2026 13:36

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts:2389

  • PR description says locale/resource changes now call notifyDimensionChange(true) (to regenerate columns and synchronously bump pipeTrigger + detectChanges()), but the current onResourceChangeHandle callback in ngAfterContentInit still calls setupColumns() directly (see pivot-grid.component.ts:998-1002). That mismatch likely means dimension headers can still update a cycle late after locale changes.
        ref.instance.header = dim?.headerFormatter != null ? (dim.headerFormatter(rawHeader, dim, undefined) ?? rawHeader) : rawHeader;
        ref.instance.field = key;

Comment thread projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 13:49

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts
Copilot AI review requested due to automatic review settings July 24, 2026 16:49

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts:1002

  • notifyDimensionChange(true) calls setupColumns() (which triggers autogenerateColumns() and already increments pipeTrigger) and then increments pipeTrigger again. In this onResourceChange callback (outside Angular zone) you mainly need to regenerate columns and run detectChanges() synchronously; calling setupColumns() + cdr.detectChanges() avoids the redundant pipeTrigger increment while keeping the immediate UI update.
            onResourceChangeHandle(this.destroy$, () => {
                this.setDateDimensionsLocaleData();
                // Use notifyDimensionChange to also increment pipeTrigger and run detectChanges synchronously,
                // since this callback fires outside Angular's zone and markForCheck() alone is not enough.
                this.notifyDimensionChange(true);

@Hristo313
Hristo313 requested a review from skrustev July 24, 2026 16:59
Comment thread projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 17:10

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts:2390

  • The PR description says locale/resource changes now call notifyDimensionChange(true) so pipeTrigger++ and cdr.detectChanges() run immediately (avoiding the “one cycle behind” header update). However, the current implementation still calls setupColumns() directly inside the onResourceChangeHandle callback (see pivot-grid.component.ts:998-1002), and notifyDimensionChange (pivot-grid.component.ts:1035-1041) is not used. If the intent is to fix immediate header refresh on locale change, the resource-change handler should be updated accordingly.
        const parentPath = parent != null ? parent.field + this.pivotKeys.columnDimensionSeparator : null;
        const rawHeader = parentPath != null && key.startsWith(parentPath) ? key.substring(parentPath.length) : key;
        const dim = value.dimension as IPivotDimension;
        ref.instance.header = dim?.headerFormatter != null ? (dim.headerFormatter(rawHeader, dim, undefined) ?? rawHeader) : rawHeader;
        ref.instance.field = key;

@skrustev
skrustev self-requested a review July 24, 2026 17:30
@skrustev skrustev added ❌ status: awaiting-test PRs awaiting manual verification and removed ✅ status: verified Applies to PRs that have passed manual verification labels Jul 24, 2026
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.

Pivot grid date dimension values are not localized

5 participants