Skip to content

Commit

Permalink
chore: Table::column_heading closures now get the NodeRef<html::Th> a…
Browse files Browse the repository at this point in the history
…s parameter
  • Loading branch information
emirror-de committed Oct 10, 2024
1 parent ee32356 commit c5a6630
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/leptos/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn Table<D, R>(
#[prop(into)]
data: MaybeSignal<D>,
/// A list of closures defining the column heading.
column_heading: Vec<Box<dyn Fn() -> Fragment>>,
column_heading: Vec<Box<dyn Fn(NodeRef<html::Th>) -> Fragment>>,
/// A list of closures that return the contents of each column.
columns: Vec<Box<dyn Fn(&R) -> Fragment>>,
) -> impl IntoView
Expand All @@ -48,8 +48,19 @@ where
// Used for inserting custom sort algorithms via leptos-meta
provide_meta_context();

let heading_items =
move || column_heading.iter().map(|head| head()).collect::<Vec<_>>();
let heading_items = column_heading
.into_iter()
.map(|head| {
move || {
let ref_th = create_node_ref::<html::Th>();
view! {
<th node_ref=ref_th>
{ head(ref_th) }
</th>
}
}
})
.collect::<Vec<_>>();

let ref_table = create_node_ref::<leptos::html::Table>();
let init_table = move || {
Expand Down

0 comments on commit c5a6630

Please sign in to comment.