From 5c0508d91cf1ecc85cfc38b152f676add907404d Mon Sep 17 00:00:00 2001 From: Adrien Maston Date: Wed, 18 Feb 2026 18:19:37 +0100 Subject: [PATCH 1/6] Don't show "no match" when not searching anything yet --- app/assets/stylesheets/search.css | 5 +++++ app/views/searches/show.html.erb | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/search.css b/app/assets/stylesheets/search.css index 5691ac5e5..32dec66b3 100644 --- a/app/assets/stylesheets/search.css +++ b/app/assets/stylesheets/search.css @@ -129,4 +129,9 @@ summary { padding-inline: 0; } } + .search-perma--empty { + .search { + display: none; + } + } } diff --git a/app/views/searches/show.html.erb b/app/views/searches/show.html.erb index 776ab9d38..197eebab2 100644 --- a/app/views/searches/show.html.erb +++ b/app/views/searches/show.html.erb @@ -1,4 +1,4 @@ -<% @page_title = params.has_key?(:q) ? "Search results for \"#{params[:q]}\"" : "Search" %> +<% @page_title = !params[:q].blank? ? "Search results for \"#{params[:q]}\"" : "Search" %> <% content_for :header do %>
@@ -8,7 +8,7 @@

<%= @page_title %>

<% end %> -
+<%= tag.div(class: token_list("search-perma", {"search-perma--empty": params[:q].blank?}, "margin-block-start")) do %> <%= render "form", query_terms: params[:q] %> <%= turbo_frame_tag "bar_content" do %> <% if @card %> @@ -17,4 +17,4 @@ <%= render "results", page: @page %> <% end %> <% end %> -
+<% end %> From 0e1feb0f3f449ba2b73bee1d1e1971fabf3ccf7e Mon Sep 17 00:00:00 2001 From: Adrien Maston Date: Thu, 19 Feb 2026 12:06:49 +0100 Subject: [PATCH 2/6] Create @query in controller instead of testing for blank? --- app/controllers/searches_controller.rb | 1 + app/views/searches/show.html.erb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/searches_controller.rb b/app/controllers/searches_controller.rb index 5176cea02..e968edbc3 100644 --- a/app/controllers/searches_controller.rb +++ b/app/controllers/searches_controller.rb @@ -2,6 +2,7 @@ class SearchesController < ApplicationController include Turbo::DriveHelper def show + @query = params[:q].blank? ? nil : params[:q] if card = Current.user.accessible_cards.find_by_id(params[:q]) @card = card else diff --git a/app/views/searches/show.html.erb b/app/views/searches/show.html.erb index 197eebab2..235ab0915 100644 --- a/app/views/searches/show.html.erb +++ b/app/views/searches/show.html.erb @@ -1,4 +1,4 @@ -<% @page_title = !params[:q].blank? ? "Search results for \"#{params[:q]}\"" : "Search" %> +<% @page_title = @query ? "Search results for \"#{@query}\"" : "Search" %> <% content_for :header do %>
@@ -8,8 +8,8 @@

<%= @page_title %>

<% end %> -<%= tag.div(class: token_list("search-perma", {"search-perma--empty": params[:q].blank?}, "margin-block-start")) do %> - <%= render "form", query_terms: params[:q] %> +<%= tag.div(class: token_list("search-perma", {"search-perma--empty": !@query}, "margin-block-start")) do %> + <%= render "form", query_terms: @query %> <%= turbo_frame_tag "bar_content" do %> <% if @card %> <%= auto_submit_form_with url: card_path(@card), method: :get, data: { turbo_action: "advance", turbo_frame: "_top", search_redirect: true } %> From 542777409c2b5ad78d68536cb2686615ff0562d7 Mon Sep 17 00:00:00 2001 From: Adrien Maston Date: Thu, 19 Feb 2026 12:07:08 +0100 Subject: [PATCH 3/6] Add test --- test/controllers/searches_controller_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/controllers/searches_controller_test.rb b/test/controllers/searches_controller_test.rb index 2493fe43f..11bac3bc9 100644 --- a/test/controllers/searches_controller_test.rb +++ b/test/controllers/searches_controller_test.rb @@ -15,6 +15,10 @@ class SearchesControllerTest < ActionDispatch::IntegrationTest end test "search" do + # Search query is blank + get search_path(q: "", script_name: "/#{@account.external_account_id}") + assert @query.nil? + # Searching by card title get search_path(q: "broken", script_name: "/#{@account.external_account_id}") assert_select "li .search__title", text: /Layout is broken/ From 97f2f677d600e8661c560409a156f464469cba85 Mon Sep 17 00:00:00 2001 From: Adrien Maston Date: Thu, 19 Feb 2026 14:04:14 +0100 Subject: [PATCH 4/6] Don't render empty state instead of hiding it --- app/assets/stylesheets/search.css | 5 ----- app/controllers/searches_controller.rb | 4 ++-- app/views/searches/_results.html.erb | 2 +- app/views/searches/show.html.erb | 6 +++--- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/search.css b/app/assets/stylesheets/search.css index 32dec66b3..5691ac5e5 100644 --- a/app/assets/stylesheets/search.css +++ b/app/assets/stylesheets/search.css @@ -129,9 +129,4 @@ summary { padding-inline: 0; } } - .search-perma--empty { - .search { - display: none; - } - } } diff --git a/app/controllers/searches_controller.rb b/app/controllers/searches_controller.rb index e968edbc3..b849f04f1 100644 --- a/app/controllers/searches_controller.rb +++ b/app/controllers/searches_controller.rb @@ -3,10 +3,10 @@ class SearchesController < ApplicationController def show @query = params[:q].blank? ? nil : params[:q] - if card = Current.user.accessible_cards.find_by_id(params[:q]) + if card = Current.user.accessible_cards.find_by_id(@query) @card = card else - set_page_and_extract_portion_from Current.user.search(params[:q]) + set_page_and_extract_portion_from Current.user.search(@query) @recent_search_queries = Current.user.search_queries.order(updated_at: :desc).limit(10) end end diff --git a/app/views/searches/_results.html.erb b/app/views/searches/_results.html.erb index 0b622e95d..573d20397 100644 --- a/app/views/searches/_results.html.erb +++ b/app/views/searches/_results.html.erb @@ -1,6 +1,6 @@