Experiment/data table integration - #24494
Draft
myabc wants to merge 8 commits into
Draft
Conversation
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.
Contributor
There was a problem hiding this comment.
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::DataTableRenderingto render legacy table DSL throughPrimer::OpenProject::DataTable(sorting, empty state, pagination, actions column). - Add
OpPrimer::ResponsiveDataTableComponentand responsive styles to emulate BorderBox behavior on mobile while using DataTable. - Extend
RowComponent/BorderBoxRowComponenttemplates to support rendering a single column (or actions) viarender_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_tableinstantiates a new row component multiple times per row (forrow_classesandrow_data). SinceRowComponentcomputes memoized values likecolumn_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 }
)
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
What are you trying to accomplish?
Screenshots
What approach did you choose and why?
Merge checklist