Skip to content

Commit 2602f47

Browse files
myabcclaude
andcommitted
Eagerly execute column config blocks instead of forcing render
Change `renders_many :columns` to a lambda slot that executes the configuration block at creation time. This eliminates the fragile `header.column.to_s # force rendering` pattern in the template, which relied on rendering a component purely for side effects. The Column#call method is also removed since Column is no longer rendered as a component — it serves as a configuration holder. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent fa9f7a6 commit 2602f47

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

app/components/primer/open_project/data_table.html.erb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<% table.with_head(classes: "TableHead") do |thead| %>
88
<% thead.with_row(classes: "TableRow") do |tr| %>
99
<% headers.each do |header| %>
10-
<% header.column.to_s # force rendering %>
1110
<% if header.sortable? %>
1211
<%
1312
tr.with_header(

app/components/primer/open_project/data_table.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ class DataTable < Primer::Component
4242
Primer::BaseComponent.new(**system_arguments)
4343
}
4444

45-
renders_many :columns, Column
45+
renders_many :columns, ->(**args, &block) {
46+
column = Column.new(**args)
47+
block&.call(column)
48+
column
49+
}
4650

4751
# @param data [Array, ActiveRecord::Relation]
4852
# A collection of rows that will be rendered inside the table

app/components/primer/open_project/data_table/column.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ def header?
6868
@header.present? || super
6969
end
7070

71-
def call
72-
content
73-
end
74-
7571
def render_cell(row)
7672
return @cell_block.call(row) if @cell_block
7773
return unless field

0 commit comments

Comments
 (0)