Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pivot table crashes when setting hide empty columns #1747

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

jenniferarnesen
Copy link
Collaborator

@jenniferarnesen jenniferarnesen commented Jan 24, 2025

Fixes DHIS2-17876

Check that data[row] exists before accessing it.

I think this is where the error was introduced: https://github.com/dhis2/analytics/pull/1567/files#diff-cecda9e65f89fb79253f45505c2d7587509d804de707bfd659ee82d97234daa9R573

chore: syntax eerror

chore: more debugging

chore: more debugging 1

fix: more logging and potential fix

fix: check that data[row] exists first
Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

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

LGTM

An alternative would be to use optional chaining:

!!(this.data[row]?.[column])

But this should work just as well. I checked that data[row][column] should always be either undefined or an object/array, so we shouldn't run into issues with false-ish 0 or "". Would be good to refactor this to typescript though so that's actually guaranteed.

@jenniferarnesen jenniferarnesen merged commit f8c01cb into master Feb 4, 2025
3 checks passed
@jenniferarnesen jenniferarnesen deleted the fix/pivot-table-empty-row-crash branch February 4, 2025 09:27
dhis2-bot added a commit that referenced this pull request Feb 4, 2025
## [26.10.2](v26.10.1...v26.10.2) (2025-02-04)

### Bug Fixes

* pivot table crashes when setting hide empty columns ([#1747](#1747)) ([f8c01cb](f8c01cb))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 26.10.2 🎉

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.

4 participants