Merge pull request #2567 from basecamp/mobile/fix-empty-search

This commit is contained in:
Adrien Maston
2026-02-19 14:28:54 +01:00
committed by GitHub
4 changed files with 12 additions and 6 deletions
+4 -2
View File
@@ -2,10 +2,12 @@ class SearchesController < ApplicationController
include Turbo::DriveHelper
def show
if card = Current.user.accessible_cards.find_by_id(params[:q])
@query = params[:q].blank? ? nil : 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
+1 -1
View File
@@ -1,6 +1,6 @@
<section class="search">
<div class="search__results">
<% unless page.used? %>
<% if !page.used? && query %>
<div class="search__blank-slate blank-slate">
No matches
</div>
+3 -3
View File
@@ -1,4 +1,4 @@
<% @page_title = params.has_key?(:q) ? "Search results for \"#{params[:q]}\"" : "Search" %>
<% @page_title = @query ? "Search results for \"#{@query}\"" : "Search" %>
<% content_for :header do %>
<div class="header__actions header__actions--start">
@@ -9,12 +9,12 @@
<% end %>
<div class="search-perma margin-block-start">
<%= render "form", query_terms: params[:q] %>
<%= 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 } %>
<% else %>
<%= render "results", page: @page %>
<%= render "results", page: @page, query: @query %>
<% end %>
<% end %>
</div>
@@ -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/