From 82e3ba8ef769dffbe110eb8f43f530b8f6ee867c Mon Sep 17 00:00:00 2001 From: Guillem Arias Date: Mon, 18 May 2026 22:16:38 +0200 Subject: [PATCH] fix(goals): keep archived cards out of the filter loop entirely MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The earlier 'filter archived too' attempts kept toggling the archived section based on chip state, which produced more confusion than value (filter shows partial counts, archived hides on some chips, etc.). Step back: archived stays in its own collapsed-by-default section, always visible, never reacts to the chip / search filter. Render the cards with filterable: false so they don't add a filter target in the first place — no JS handling needed, and the active grid + chips behave exactly like they did before this whole thread. --- app/components/goals/card_component.html.erb | 2 +- app/components/goals/card_component.rb | 5 +++-- app/controllers/goals_controller.rb | 7 ++++--- app/views/goals/index.html.erb | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/components/goals/card_component.html.erb b/app/components/goals/card_component.html.erb index 768a3ae30..b3a521654 100644 --- a/app/components/goals/card_component.html.erb +++ b/app/components/goals/card_component.html.erb @@ -1,5 +1,5 @@
" - data-goals-filter-target="card" + <% if filterable %>data-goals-filter-target="card"<% end %> data-goal-name="<%= goal.name %>" data-goal-status="<%= goal.display_status %>">
diff --git a/app/components/goals/card_component.rb b/app/components/goals/card_component.rb index 6c0a1e287..6ca6a32a5 100644 --- a/app/components/goals/card_component.rb +++ b/app/components/goals/card_component.rb @@ -2,11 +2,12 @@ class Goals::CardComponent < ApplicationComponent RING_SIZE = 64 RING_STROKE = 6 - def initialize(goal:) + def initialize(goal:, filterable: true) @goal = goal + @filterable = filterable end - attr_reader :goal + attr_reader :goal, :filterable def progress_percent goal.progress_percent diff --git a/app/controllers/goals_controller.rb b/app/controllers/goals_controller.rb index 0605bd3f0..287c3f10a 100644 --- a/app/controllers/goals_controller.rb +++ b/app/controllers/goals_controller.rb @@ -20,9 +20,10 @@ class GoalsController < ApplicationController .sort_by { |g| [ g.paused? ? 3 : ACTIVE_STATUS_RANK.fetch(g.status, 4), g.name.downcase ] } @completed_goals = all_goals.select { |g| g.state == "completed" }.sort_by { |g| g.name.downcase } @archived_goals = all_goals.select { |g| g.state == "archived" } - # Completed goals join the chip-filterable grid below the active ones so - # the `completed` chip can isolate them. Archived stays in the separate - # collapsed-by-default section below. + # Completed goals join the chip-filterable grid below the active ones + # so the `completed` chip can isolate them. Archived stays in a + # separate collapsed-by-default section, opted out of the filter + # entirely (rendered with filterable: false). @grid_goals = @active_goals + @completed_goals @linkable_account_count = Current.family.accounts.where(accountable_type: "Depository").visible.count diff --git a/app/views/goals/index.html.erb b/app/views/goals/index.html.erb index e991ad877..b5b6873d1 100644 --- a/app/views/goals/index.html.erb +++ b/app/views/goals/index.html.erb @@ -182,7 +182,7 @@
<% @archived_goals.each do |goal| %> - <%= render Goals::CardComponent.new(goal: goal) %> + <%= render Goals::CardComponent.new(goal: goal, filterable: false) %> <% end %>