Skip to content

fix: preserve period ids for program-level time dimensions in event PTs#1838

Merged
edoardo merged 1 commit into
masterfrom
fix/cell-type-crash
Jun 25, 2026
Merged

fix: preserve period ids for program-level time dimensions in event PTs#1838
edoardo merged 1 commit into
masterfrom
fix/cell-type-crash

Conversation

@edoardo

@edoardo edoardo commented Jun 25, 2026

Copy link
Copy Markdown
Member

Implements DHIS2-XXXX


Key features

  1. Fixes a crash that blanked out some enrollment/event Pivot Tables with a console error (Cannot read properties of undefined (reading 'cellType')).

Description

Certain enrollment Pivot Tables — those using a program-level time dimension such as enrollmentdate on rows/columns — would crash and render nothing when the query returned no matching data.

Cause. Two issues combined:

  • When transforming the analytics response, the period buckets for bare program-level time dimensions (e.g. enrollmentdate, incidentdate) were being re-derived from the returned data rows. For a query with no data this produced an empty set of periods, even though the server had returned the full period range. (Their program-stage-scoped equivalents, e.g. .eventdate, were already handled correctly.)
    The result was a Pivot Table with zero columns.
  • The table renderer did not handle a "zero rows or zero columns" matrix gracefully and threw while trying to render a cell that didn't exist.

Fix.

  • The response transformation now preserves the server-provided period members for program-level time dimensions, consistent with how period and organisation-unit dimensions are already treated. So the table keeps its full set of period columns even when there's no data.
  • The renderer is hardened so that a table with no rows or no columns renders as an empty table instead of throwing — defense-in-depth against any other source of an empty matrix.

Behaviour note. A Pivot Table using a program-level time dimension now shows all periods in the selected range (e.g. all of the last 12 months), including empty ones, matching the behaviour of other period dimensions. The "hide empty rows/columns" options continue to control whether empty periods
are shown. Previously these dimensions silently dropped periods that had no data.


TODO

  • Tests added
  • PRs for all affected apps created
  • Storybook added

Screenshots

Example of PT visualization that returns no data.

Before:

Screenshot 2026-06-25 at 12 51 20

After:

Screenshot 2026-06-25 at 12 50 21

Program-level time dimensions (e.g. enrollmentdate) had their period
buckets re-derived from data rows, collapsing the pivot table to zero columns
when a query returned no data and crashing the renderer.
Addded checks to avoid reading from undefined in the renderer.
@edoardo edoardo merged commit 9ee7eb3 into master Jun 25, 2026
8 of 9 checks passed
@edoardo edoardo deleted the fix/cell-type-crash branch June 25, 2026 12:31
@sonarqubecloud

Copy link
Copy Markdown

dhis2-bot added a commit that referenced this pull request Jun 25, 2026
## [29.5.4](v29.5.3...v29.5.4) (2026-06-25)

### Bug Fixes

* preserve period ids for program-level time dimensions in event PTs ([#1838](#1838)) ([9ee7eb3](9ee7eb3))
@dhis2-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 29.5.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

3 participants