Skip to content

Bug: Raw submissions table only shows columns from first submission (missing fields) #36

Description

@ChitkulLakshya

Bug: Raw submissions table only shows columns from first submission (missing fields)

File: src/pages/TemplateDetailAnalytics.jsx:125-127

Problem

The raw submissions table builds its column headers from only the first submission's data:

const allSubmissionKeys = submissions.length > 0
  ? Object.keys(submissions[0].submittedData || {})
  : [];

If later submissions have additional fields (e.g., optional fields that only some users fill), those columns won't appear. Conversely, if the first submission is missing a field that later submissions have, that data is invisible.

Impact

  • Incomplete data display in the submissions table
  • Paginated data changes columns on each page (page 1 might have different keys than page 2)

Fix

Collect all unique keys across all submissions on the current page:

const allSubmissionKeys = submissions.length > 0
  ? [...new Set(submissions.flatMap(s => Object.keys(s.submittedData || {})))]
  : [];

Or better: use the template's enabledFields from detail.enabledFields since that defines the complete schema:

const allSubmissionKeys = detail.enabledFields;

Severity

Medium — Data display issue, not a crash. But users may miss seeing fields that don't appear in the first row.

Phase

Introduced in Phase 2 (PR #27, merged).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions