Skip to content

Commit

Permalink
Layout super nav header: Add search autocomplete
Browse files Browse the repository at this point in the history
This changes the layout super navigation header to use the new
`search_with_autocomplete` component instead of the vanilla `search`
one.
  • Loading branch information
csutter authored and kevindew committed Dec 10, 2024
1 parent 4496b31 commit a0e6ada
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
label: "Site-wide",
}
) do %>
<%= render "govuk_publishing_components/components/search", {
<%= render "govuk_publishing_components/components/search_with_autocomplete", {
name: "keywords",
inline_label: false,
label_size: "m",
Expand All @@ -326,6 +326,8 @@
size: "large",
margin_bottom: 0,
disable_corrections: true,
source_url: [Plek.new.website_root, "/api/search/autocomplete.json"].join,
source_key: "suggestions"
} %>
<% end %>
</div>
Expand Down
2 changes: 2 additions & 0 deletions spec/component_guide/component_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
@import 'govuk_publishing_components/components/print-link';
@import 'govuk_publishing_components/components/related-navigation';
@import 'govuk_publishing_components/components/search';
@import 'govuk_publishing_components/components/search-with-autocomplete';
@import 'govuk_publishing_components/components/skip-link';
@import 'govuk_publishing_components/components/step-by-step-nav';
@import 'govuk_publishing_components/components/step-by-step-nav-header';
Expand Down Expand Up @@ -98,6 +99,7 @@
//= require govuk_publishing_components/components/layout-header
//= require govuk_publishing_components/components/layout-super-navigation-header
//= require govuk_publishing_components/components/print-link
//= require govuk_publishing_components/components/search-with-autocomplete
//= require govuk_publishing_components/components/skip-link
//= require govuk_publishing_components/components/step-by-step-nav
//= require govuk_publishing_components/components/tabs"
Expand Down
5 changes: 5 additions & 0 deletions spec/components/layout_super_navigation_header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ def component_name
assert_select ".js-module-initialised[data-module=\"super-navigation-mega-menu\"]", false
end

it "includes the search_with_autocomplete component with correct URL" do
render_component({})
assert_select ".gem-c-search-with-autocomplete[data-source-url='http://www.dev.gov.uk/api/search/autocomplete.json']"
end

it "adds GA4 tracking" do
render_component({})

Expand Down

0 comments on commit a0e6ada

Please sign in to comment.