Skip to content

Commit 8d7ea33

Browse files
committed
Change the search button click behavior and always show topics
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
1 parent cded2c9 commit 8d7ea33

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

app/assets/stylesheets/components/sidebar.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@
88
margin-bottom: var(--spacing-8);
99
}
1010

11+
.sidebar-section.is-search-focus .sidebar-heading {
12+
background: linear-gradient(135deg, var(--color-bg-sidebar-header), var(--color-primary-2));
13+
border-radius: 999px;
14+
box-shadow: var(--shadow-sm);
15+
}
16+
17+
.sidebar-section.is-search-focus .sidebar-content {
18+
border-radius: 16px;
19+
box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
20+
background: var(--color-bg-card);
21+
border: var(--border-width) solid var(--color-primary-200);
22+
}
23+
24+
.sidebar-section.is-search-focus .search-input {
25+
border-color: var(--color-primary-300);
26+
box-shadow: var(--shadow-focus);
27+
}
28+
29+
.sidebar-section.is-search-focus .search-button {
30+
border-color: var(--color-primary-300);
31+
background: var(--color-bg-hover);
32+
}
33+
1134
.sidebar .search-input {
1235
width: 100%;
1336
padding: var(--spacing-3) var(--spacing-4);

app/controllers/topics_controller.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@ def read_all
9595
def search
9696
@search_query = params[:q].to_s.strip
9797

98-
if @search_query.present?
99-
load_cached_search_results
100-
else
101-
base_query = topics_base_query(search_query: @search_query)
102-
apply_cursor_pagination(base_query)
103-
@new_topics_count = 0
98+
if @search_query.blank?
99+
respond_to do |format|
100+
format.html { redirect_to topics_path(focus: 1) }
101+
format.turbo_stream { redirect_to topics_path(focus: 1) }
102+
end
103+
return
104104
end
105105

106+
load_cached_search_results
107+
106108
preload_commitfest_summaries
107109
preload_participation_flags if user_signed_in?
108110

app/views/layouts/application.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ html data-theme="light"
4242
span.tagline PostgreSQL Hackers Archive
4343
.nav-links
4444
= link_to "Topics", topics_path, class: "nav-link"
45-
= link_to "Search", search_topics_path, class: "nav-link"
45+
= link_to "Search", topics_path(focus: 1), class: "nav-link"
4646
= link_to "Statistics", stats_path, class: "nav-link"
4747
.nav-right
4848
button.nav-link.theme-toggle type="button" aria-label="Toggle theme" data-controller="theme" data-action="click->theme#toggle"

app/views/topics/_sidebar.html.slim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
button.mark-aware-button data-action="click->topics-aware#markVisibleAware" Mark displayed threads aware
99
button.mark-aware-button.secondary data-action="click->topics-aware#markAllAware" Mark everything up to now aware
1010

11-
.sidebar-section
11+
.sidebar-section class=(params[:focus].present? ? "is-search-focus" : nil)
1212
h3.sidebar-heading Search
1313
.sidebar-search.sidebar-content
1414
= form_with url: search_topics_path, method: :get, local: true do |f|
15-
= f.text_field :q, placeholder: "Search topics and messages...", class: "search-input", value: search_query
15+
= f.text_field :q, placeholder: "Search topics and messages...", class: "search-input", value: search_query, autofocus: params[:focus].present?
1616
= f.submit "Search", class: "search-button"
1717

1818
.sidebar-section

app/views/topics/search.html.slim

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,3 @@
3434
h3 No results found
3535
p Try different search terms or browse all topics
3636
= link_to "Browse All Topics", topics_path, class: "browse-link"
37-
38-
- else
39-
.search-help
40-
h3 Search the PostgreSQL Hackers Archive
41-
p Enter keywords to search through topic titles and message content
42-
= link_to "Browse All Topics", topics_path, class: "browse-link"

0 commit comments

Comments
 (0)