Skip to content

PLU-591: [show-multiple-rows-4]: add frontend table variable#1539

Open
m0nggh wants to merge 1 commit intofeat/find-multiple-rows/table-var-postmanfrom
feat/find-multiple-rows/frontend-table-variable
Open

PLU-591: [show-multiple-rows-4]: add frontend table variable#1539
m0nggh wants to merge 1 commit intofeat/find-multiple-rows/table-var-postmanfrom
feat/find-multiple-rows/frontend-table-variable

Conversation

@m0nggh
Copy link
Copy Markdown
Contributor

@m0nggh m0nggh commented Apr 10, 2026

TL;DR

Added table variable support to rich text editor with column selection and preview functionality for email body fields.

What changed?

  • Created TableVariable TipTap extension and TableVariablePill component for rendering interactive table previews in rich text fields
  • Added supportTableDisplay flag to enable table variable insertion in specific fields (currently email body in Postman)
  • Implemented hex encoding/decoding utilities for storing column selection state in variable IDs
  • Enhanced table variable metadata extraction to include column information, sample rows, and total row count
  • Updated variable insertion logic to differentiate between table display mode and for-each mode
  • Modified display text format from "Preview X row(s)" to "X row(s)" with proper pluralization
  • Added context provider for rich text editor to manage table display capabilities

Screenshots

Screen.Recording.2026-04-10.at.9.20.27.PM.mov

How to test?

  1. Create a workflow with a step that outputs table data (FormSG, M365 Excel, or Tiles)
  2. Add a "Send transactional email" action from Postman
  3. In the email body field, insert a table variable - it should render as an interactive preview with column selection
  4. Test column selection via the "Edit" button in the table preview
  5. Verify the same table variable in a for-each field still inserts as a simple text variable
  6. Check that the table preview shows proper styling and sample data

Frontend changes to check after pointed out by Vedant:

  1. Variable item should show X rows and a view button
image

Why make this change?

This enhancement improves the user experience when working with table data in email templates by providing visual previews and allowing users to select specific columns for display, making it easier to create well-formatted emails with tabular data.

Copy link
Copy Markdown
Contributor Author

m0nggh commented Apr 10, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label lfg to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@m0nggh m0nggh changed the title add frontend table variable PLU-591: [show-multiple-rows-4]: add frontend table variable Apr 10, 2026
@linear
Copy link
Copy Markdown

linear bot commented Apr 10, 2026

@m0nggh m0nggh marked this pull request as ready for review April 10, 2026 13:16
@m0nggh m0nggh requested a review from a team as a code owner April 10, 2026 13:16
Comment thread packages/backend/src/apps/formsg/common/get-data-out-metadata.ts Outdated
Comment thread packages/frontend/src/components/VariablesList/TableVariableItem.tsx Outdated
@m0nggh m0nggh force-pushed the feat/find-multiple-rows/frontend-table-variable branch 2 times, most recently from 83eced8 to 7efa107 Compare April 10, 2026 13:53
@m0nggh m0nggh force-pushed the feat/find-multiple-rows/table-var-postman branch from 9d59663 to 15e0687 Compare April 10, 2026 13:53
@m0nggh m0nggh force-pushed the feat/find-multiple-rows/frontend-table-variable branch from 7efa107 to 05eca91 Compare April 11, 2026 02:11
@m0nggh m0nggh force-pushed the feat/find-multiple-rows/table-var-postman branch from 15e0687 to ce7775d Compare April 11, 2026 02:11
@m0nggh m0nggh force-pushed the feat/find-multiple-rows/table-var-postman branch from ce7775d to 6d4c268 Compare April 15, 2026 02:47
@m0nggh m0nggh force-pushed the feat/find-multiple-rows/frontend-table-variable branch from 05eca91 to 911621f Compare April 15, 2026 02:47
Comment on lines +204 to +205
const displayValue =
tableVar?.displayedValue ?? `${tableVar?.totalRowCount ?? 0} rows`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pluralization bug in fallback display value. When totalRowCount is 1, the fallback displays "1 rows" instead of "1 row", inconsistent with the backend pluralization logic.

const displayValue =
  tableVar?.displayedValue ??
  `${tableVar?.totalRowCount ?? 0} row${tableVar?.totalRowCount !== 1 ? 's' : ''}`
Suggested change
const displayValue =
tableVar?.displayedValue ?? `${tableVar?.totalRowCount ?? 0} rows`
const displayValue =
tableVar?.displayedValue ?? `${tableVar?.totalRowCount ?? 0} row${tableVar?.totalRowCount !== 1 ? 's' : ''}`

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant