From ebf89808f5171c315b13193c12ddd1c98a90830b Mon Sep 17 00:00:00 2001 From: Mark Hendriksen Date: Sun, 15 Feb 2026 13:25:28 +0100 Subject: [PATCH] Fix separators in breakdown table view (#996) * Fix separators in breakdown table view Correct conditional logic for rendering column separators (rulers) in the reports breakdown table. The top-level check now compares idx to groups.size instead of group.size, and the subcategory check compares idx to group[:subcategories].size. This ensures separators are shown between categories and subcategories correctly, avoiding missing or extra rulers. * Fix subcategory index variable name in partial Rename the inner loop index from `idx` to `sub_idx` in app/views/reports/_breakdown_table.html.erb to avoid shadowing the outer `idx`. This ensures the conditional that renders the separator (`shared/ruler`) uses the correct index for subcategories, preventing incorrect rendering of separators between subcategory rows. * Fix conditional block order in breakdown table Reorder ERB tags to properly nest the subcategory conditional and the ruler render in the reports breakdown partial. This ensures the divider is only rendered between subcategories and prevents mismatched ERB/end tags that could break template rendering. --- app/views/reports/_breakdown_table.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/reports/_breakdown_table.html.erb b/app/views/reports/_breakdown_table.html.erb index 7f6b897be..2034ba4cb 100644 --- a/app/views/reports/_breakdown_table.html.erb +++ b/app/views/reports/_breakdown_table.html.erb @@ -37,21 +37,21 @@ color_class: color_class, level: :category %> - <% if idx < group.size - 1 %> + <% if idx < groups.size - 1 %> <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> <% end %> <%# Render subcategories if present %> <% if group[:subcategories].present? && group[:subcategories].any? %> - <% group[:subcategories].each_with_index do |subcategory, idx| %> + <% group[:subcategories].each_with_index do |subcategory, sub_idx| %> <%= render "reports/category_row", item: subcategory, total: total, color_class: color_class, level: :subcategory %> - <% end %> - <% if idx < group.size - 1 %> - <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> + <% if sub_idx < group[:subcategories].size - 1 %> + <%= render "shared/ruler", classes: "mx-3 lg:mx-4" %> + <% end %> <% end %> <% end %> <% end %>