Skip to content

feat(dataTable): improve repeat group responses handling DEV-2400#7226

Open
magicznyleszek wants to merge 11 commits into
mainfrom
leszek/dev-2400-repeat-group-blank-table
Open

feat(dataTable): improve repeat group responses handling DEV-2400#7226
magicznyleszek wants to merge 11 commits into
mainfrom
leszek/dev-2400-repeat-group-blank-table

Conversation

@magicznyleszek

@magicznyleszek magicznyleszek commented Jul 8, 2026

Copy link
Copy Markdown
Member

🗒️ Checklist

  1. run linter locally
  2. update developer docs (API, README, inline, etc.), if any
  3. for user-facing doc changes create a Zulip thread at #Support Docs Updates, if any
  4. draft PR with a title <type>(<scope>)<!>: <title> DEV-1234
  5. assign yourself, tag PR: at least Front end and/or Back end or workflow
  6. fill in the template below and delete template comments
  7. review thyself: read the diff and repro the preview as written
  8. open PR & confirm that CI passes & request reviewers, if needed
  9. act on any greptile review below a 5/5 score or leave comment explaining why you won't
  10. delete this checklist section from the final squash commit before merging

📣 Summary

Data Table repeat-group handling was stabilized for nested structures: values no longer disappear for valid nested repeat paths, andrepeat answers are (still) shown as a simple flat comma-separated list.

💭 Notes

Changes in this PR:

  1. Fixed the main issue where repeat-related Data Table cells could appear empty even though submission data existed.
  2. Improved repeat path traversal so nested answers are found even when data is stored under parent repeat/group branches rather than the exact column key.
  3. Preserved compatibility behavior (including deleted attachment rendering) while simplifying repeat formatting flow.
  4. Expanded/updated tests for repeat edge cases:
    • nested repeats and repeats-inside-repeats,
    • deep multi-level nesting,
    • missing/invalid branches,
    • unanswered branches with placeholder mode,
    • deleted media attachments.

Why this helps:

  1. Users see actual repeat answers instead of blank cells in nested scenarios.
  2. Table output is simpler and consistent with prior behavior expectations (plain inline list).
  3. Repeat extraction logic is easier to maintain and safer to evolve.

👀 Preview steps

  1. Have a project Nested Repeat Houses.xlsx and at least one submission with deep nested data (Countries → Cities → Streets → Houses → Inhabitants).
  2. Go to Project → Data → Table.
  3. Locate the column Countries / Cities / Streets / Houses / Inhabitants / Inhabitant name.
  4. On main, nested repeat values may be blank or inconsistently resolved in some cases.
  5. On PR, values are resolved and rendered inline as a flat comma-separated list.
  6. Optionally verify another nested column (for example Inhabitant age) to confirm repeat-path handling is consistent.
  7. Optionally verify incomplete responses and deleted attachments still display safely.

@magicznyleszek

Copy link
Copy Markdown
Member Author

@greptile-apps please review

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 improves how the Submissions Data Table extracts and renders repeat-group (including deeply nested) answers, so nested repeat columns don’t appear blank when submission payloads store data at parent container paths. It also introduces a modal view for repeat cells to make deep hierarchies easier to scan.

Changes:

  • Add selectNestedRow to resolve missing nested keys by falling back to the nearest container payload when appropriate, and wire it into the Data Table column accessor.
  • Refactor repeat/group traversal + formatting into dedicated utilities (repeatGroupUtils, submissionMediaUtils) and update the repeat cell UI to render indexed inline values + a flattened indexed modal list.
  • Expand unit tests to cover nested repeat edge cases and the new nested-row selection behavior.

Reviewed changes

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

Show a summary per file
File Description
jsapp/js/components/submissions/tableUtils.ts Adds selectNestedRow to better resolve nested/repeat values from submission payloads.
jsapp/js/components/submissions/tableUtils.tests.ts Adds test coverage for selectNestedRow behavior (exact key, supplemental, parent container fallback).
jsapp/js/components/submissions/table.tsx Uses selectNestedRow as the column accessor and removes the previous class helper.
jsapp/js/components/submissions/submissionUtils.tsx Moves repeat/media helpers into dedicated modules and re-exports them for compatibility.
jsapp/js/components/submissions/submissionMediaUtils.ts New module containing getMediaAttachment previously in submissionUtils.
jsapp/js/components/submissions/repeatGroupUtils.tsx New module implementing repeat answer traversal as both a tree and a legacy flat list.
jsapp/js/components/submissions/repeatGroupUtils.tests.ts New, expanded tests for repeat traversal across nested/grouped scenarios (incl. deleted attachments).
jsapp/js/components/submissions/DataTableCell/TextModalCell.tsx Adds optional modalContent so callers can render richer modal bodies than plain text.
jsapp/js/components/submissions/DataTableCell/RepeatGroupCell.tsx Reworks repeat rendering: hierarchy-indexed inline text plus a flattened, indexed modal list.
jsapp/js/components/submissions/DataTableCell/RepeatGroupCell.module.scss Removes old repeat-cell-specific styling (now using TextModalCell).
jsapp/js/components/submissions/DataTableCell/index.tsx Routes undefined nested keys / object values into RepeatGroupCell to avoid blank nested repeat columns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread jsapp/js/components/submissions/repeatGroupUtils.tsx
Comment thread jsapp/js/components/submissions/tableUtils.ts
Comment thread jsapp/js/components/submissions/tableUtils.ts
Comment thread jsapp/js/components/submissions/tableUtils.ts
Comment thread jsapp/js/components/submissions/repeatGroupUtils.tsx
@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes blank Data Table cells for nested repeat-group columns by improving path traversal in a new repeatGroupUtils.tsx module, extracting getMediaAttachment into submissionMediaUtils.ts, and upgrading selectNestedRow in tableUtils.ts to walk ancestor paths before falling back to the root group key.

  • Core fix: getRepeatGroupAnswerTree now uses a while loop to skip missing intermediate path segments, resolving the main blank-cell regression for deeply nested repeats.
  • Routing guard (shouldRenderUndefinedNestedKeyAsRepeat): routes undefined-valued cells to RepeatGroupCell only when an array ancestor exists in the submission.
  • Test coverage: a new repeatGroupUtils.tests.ts suite covers root, grouped, nested, 4-level, partial-answer, and deleted-attachment scenarios.

Confidence Score: 5/5

Safe to merge; the changes improve nested repeat rendering without breaking the flat-list output used by existing table cells.

The flat-list rendering path used by the live Data Table is well-covered by tests and the core fix is logically sound. getRepeatGroupAnswerTree has an edge case with flattened intermediate keys but is not yet wired to any UI component, carrying no user-visible risk today.

repeatGroupUtils.tsx — the grouping-threshold condition and attachment-path annotation for nested repeats are worth revisiting before getRepeatGroupAnswerTree is wired to a modal or structured-display component.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["DataTableCell renders column"] --> B["selectNestedRow(row, key, rootParentGroup)"]
    B --> C{Exact key in row?}
    C -- Yes --> D["Return row[key]"]
    C -- No --> E{Parent path with container value?}
    E -- Yes --> F["Return row[parentPath]"]
    E -- No --> G{rootParentGroup container?}
    G -- Yes --> H["Return row[rootParentGroup]"]
    G -- No --> I["Return undefined"]
    D & F & H --> J{typeof value === 'object'?}
    I --> K{shouldRenderUndefinedNestedKeyAsRepeat?}
    K --> L{Array ancestor in submission?}
    L -- Yes --> M["Render RepeatGroupCell"]
    L -- No --> N["Render empty cell"]
    J -- Yes --> M
    J -- No --> O["Render normal cell"]
    M --> P["getRepeatGroupAnswers(submission, columnKey)"]
    P --> Q["getRepeatGroupAnswerTree: while loop walks path segments"]
    Q --> R["Flat comma-separated list"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["DataTableCell renders column"] --> B["selectNestedRow(row, key, rootParentGroup)"]
    B --> C{Exact key in row?}
    C -- Yes --> D["Return row[key]"]
    C -- No --> E{Parent path with container value?}
    E -- Yes --> F["Return row[parentPath]"]
    E -- No --> G{rootParentGroup container?}
    G -- Yes --> H["Return row[rootParentGroup]"]
    G -- No --> I["Return undefined"]
    D & F & H --> J{typeof value === 'object'?}
    I --> K{shouldRenderUndefinedNestedKeyAsRepeat?}
    K --> L{Array ancestor in submission?}
    L -- Yes --> M["Render RepeatGroupCell"]
    L -- No --> N["Render empty cell"]
    J -- Yes --> M
    J -- No --> O["Render normal cell"]
    M --> P["getRepeatGroupAnswers(submission, columnKey)"]
    P --> Q["getRepeatGroupAnswerTree: while loop walks path segments"]
    Q --> R["Flat comma-separated list"]
Loading

Reviews (8): Last reviewed commit: "Merge branch 'main' into leszek/dev-2400..." | Re-trigger Greptile

Comment thread jsapp/js/components/submissions/repeatGroupUtils.tsx
Comment thread jsapp/js/components/submissions/DataTableCell/index.tsx
@magicznyleszek

Copy link
Copy Markdown
Member Author

@greptile-apps review again

magicznyleszek and others added 5 commits July 8, 2026 16:08
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@magicznyleszek

Copy link
Copy Markdown
Member Author

@greptile-apps review again

@magicznyleszek magicznyleszek marked this pull request as ready for review July 8, 2026 15:25
Comment thread jsapp/js/components/submissions/repeatGroupUtils.tsx
@jnm jnm added the donotmerge label Jul 8, 2026
@magicznyleszek magicznyleszek marked this pull request as draft July 8, 2026 18:34
@magicznyleszek

Copy link
Copy Markdown
Member Author

@greptile-apps review again

@magicznyleszek

Copy link
Copy Markdown
Member Author

@greptile-apps review again

@magicznyleszek magicznyleszek marked this pull request as ready for review July 8, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants