Skip to content

Commit

Permalink
Layout super nav header: Correct URL for search form
Browse files Browse the repository at this point in the history
- Point form at `/search/all` instead of `/search` to avoid most users
  going through an unnecessary 301 redirect
- Use Rails's tag helper for more concise form code (in particular data
  attributes)
  • Loading branch information
csutter committed Oct 25, 2024
1 parent 8cf5470 commit 329bb5a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Layout super nav header: Correct URL for search form ([PR #4341](https://github.com/alphagov/govuk_publishing_components/pull/4341))

## 44.7.1

* Fix incorrect underline styles on share links ([PR #4337](https://github.com/alphagov/govuk_publishing_components/pull/4337))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,29 +299,30 @@
</h3>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<%
form_attributes = {
event_name: "search",
type: "header menu bar",
section: "Search GOV.UK",
action: "search",
url: "/search/all",
index_section: 3,
index_section_count: 3,
}.to_json
%>
<form
class="gem-c-layout-super-navigation-header__search-form"
id="search"
data-module="ga4-form-tracker"
data-ga4-form="<%= form_attributes %>"
data-ga4-form-include-text
data-ga4-form-no-answer-undefined
action="<%= absolute_links_helper.make_url_absolute('/search') %>"
method="get"
role="search"
aria-label="Site-wide"
>
<%= tag.form(
class: "gem-c-layout-super-navigation-header__search-form",
id: "search",
data: {
module: "ga4-form-tracker",
ga4_form: {
event_name: "search",
type: "header menu bar",
section: "Search GOV.UK",
action: "search",
url: "/search/all",
index_section: 3,
index_section_count: 3,
},
ga4_form_include_text: "",
ga4_form_no_answer_undefined: "",
},
action: absolute_links_helper.make_url_absolute("/search/all"),
method: "get",
role: "search",
aria: {
label: "Site-wide",
}
) do %>
<%= render "govuk_publishing_components/components/search", {
inline_label: false,
label_size: "m",
Expand All @@ -331,7 +332,7 @@
margin_bottom: 0,
disable_corrections: true,
} %>
</form>
<% end %>
</div>
</div>
</div>
Expand Down

0 comments on commit 329bb5a

Please sign in to comment.