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 } %>