Skip to content

Commit

Permalink
Homepage: Fix search form path
Browse files Browse the repository at this point in the history
The form points to the wrong path for search - `/search` is a landing
page, not the actual all content finder (which is `/search/all`). This
means users searching from the homepage have to go through an
unnecessary redirection.

Also cleans up the form code by using Rails's tag helper.

See also: alphagov/govuk_publishing_components#4341
  • Loading branch information
csutter committed Oct 28, 2024
1 parent 3dc7e90 commit 33102e1
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions app/views/homepage/_homepage_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@
</div>
<div class="govuk-grid-row">
<div class="homepage-header__search">
<form
action="/search"
method="get"
role="search"
data-module="ga4-form-tracker"
data-ga4-form-no-answer-undefined
data-ga4-form-include-text
data-ga4-form='{"event_name": "search", "type": "homepage", "url": "/search/all", "section": "Search", "action": "search", "index_section": 1, "index_section_count": 6}'
>
<%= tag.form(
action: "/search/all",
method: "get",
role: "search",
data: {
module: "ga4-form-tracker",
ga4_form_no_answer_undefined: "",
ga4_form_include_text: "",
ga4_form: {
event_name: "search",
type: "homepage",
url: "/search/all",
section: "Search",
action: "search",
index_section: 1,
index_section_count: 6
}
}
) do %>
<%= render "govuk_publishing_components/components/search", {
button_text: t("homepage.index.search_button"),
margin_bottom: 0,
Expand All @@ -35,8 +45,8 @@
margin_top: 5,
disable_corrections: true,
} %>
</form>
<% end %>
</div>
</div>
</div>
</header>
</header>

0 comments on commit 33102e1

Please sign in to comment.