Skip to content

Experiment/data table integration - #24494

Draft
myabc wants to merge 8 commits into
devfrom
experiment/data-table-integration
Draft

Experiment/data table integration#24494
myabc wants to merge 8 commits into
devfrom
experiment/data-table-integration

Conversation

@myabc

@myabc myabc commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Ticket

What are you trying to accomplish?

Screenshots

What approach did you choose and why?

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

myabc added 4 commits July 29, 2026 12:39
A DataTable owns its own cell elements, so rendering one of its cells
means re-entering the caller's existing RowComponent for that column
alone. Without this, every migrating table would have to rewrite its
row component.
Existing tables describe themselves with a class-level DSL that has
no DataTable equivalent. Translating that DSL once, behind the
superclass callers already name, keeps migration to a single line
and leaves every RowComponent untouched.
BorderBox callers default to no sorting, no actions column and a
blank slate, so they need their own façade over the shared rendering
engine rather than the generic one's defaults.
The component had no coverage, so a rendering change could not be
shown to preserve behaviour. Written against the current
implementation so they can act as the migration's regression gate.
The BorderBox shared examples assert class names of the framework
being replaced, so this spec asserts headings, row counts and cell
counts locally instead. The shared file stays untouched: the other
BorderBox tables still render the old markup.

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 introduces a compatibility layer to render existing TableComponent / BorderBoxTableComponent implementations using Primer::OpenProject::DataTable, including a responsive variant that preserves the BorderBox mobile UX (labels + title + blank slate) while switching to DataTable markup.

Changes:

  • Add OpPrimer::DataTableComponent + OpPrimer::DataTableRendering to render legacy table DSL through Primer::OpenProject::DataTable (sorting, empty state, pagination, actions column).
  • Add OpPrimer::ResponsiveDataTableComponent and responsive styles to emulate BorderBox behavior on mobile while using DataTable.
  • Extend RowComponent / BorderBoxRowComponent templates to support rendering a single column (or actions) via render_only:, and add component specs covering the new behavior.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
spec/components/users/table_component_spec.rb Verifies Users table renders rows/columns, sorting links, actions, custom fields, and empty state behavior.
spec/components/row_component_spec.rb Tests render_only: rendering for a single column and for the actions “cell”.
spec/components/op_primer/responsive_data_table_component_spec.rb Covers responsive DataTable rendering, mobile title, optional actions column, and blank state.
spec/components/op_primer/data_table_component_spec.rb Covers DataTable rendering (headers/rows/actions), turbo target wrapper, sorting, pagination, and header/column mismatch errors.
app/components/row_component.rb Adds render_only support and an actions sentinel constant to render partial row content.
app/components/row_component.html.erb Allows rendering either the full <tr> or only a single column/actions content.
app/components/op_primer/responsive_data_table_component.sass Adds responsive layout rules to hide headers on mobile, position actions, and style “main” column.
app/components/op_primer/responsive_data_table_component.rb New BorderBox-compatible façade using DataTableRendering plus responsive-specific hooks.
app/components/op_primer/data_table_rendering.rb New rendering module mapping legacy DSL to Primer::OpenProject::DataTable (columns/actions/sorting/empty/pagination).
app/components/op_primer/data_table_component.rb Generic TableComponent façade that enables actions column by default for parity with legacy template.
app/components/op_primer/border_box_row_component.html.erb Adds render_only: support so BorderBox rows can render a single column/actions into DataTable cells.
app/components/_index.sass Includes the new responsive DataTable styles in the components stylesheet index.
Comments suppressed due to low confidence (1)

app/components/op_primer/data_table_rendering.rb:138

  • data_table instantiates a new row component multiple times per row (for row_classes and row_data). Since RowComponent computes memoized values like column_css_classes, this adds avoidable overhead on large tables. Consider memoizing a base row instance per row and reusing it for row-level metadata.
    def data_table
      Primer::OpenProject::DataTable.new(
        rows,
        classes: data_table_classes,
        sorting: sortable? ? :external : :client,
        sort_href_builder: (sort_href_builder if sortable?),
        initial_sort_column: initial_sort_column,
        initial_sort_direction: initial_sort_direction,
        row_classes: ->(row) { row_class.new(row: row, table: self).row_css_class },
        row_data: ->(row) { row_class.new(row: row, table: self).row_data }
      )

Comment thread app/components/op_primer/data_table_rendering.rb
Comment thread app/components/op_primer/responsive_data_table_component.rb
myabc added 2 commits July 29, 2026 14:20
Out-of-range pages must not reach Primer's pagination validator, and
footer content must stay inside the Turbo replacement wrapper to avoid
duplicate siblings after updates. The actions header remains available
to assistive technology without adding visible text.
Row metadata and per-cell classes share one identity-keyed component per
row, matching the legacy BorderBox lifecycle while rendered cells retain
dedicated component instances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants