From 4ea037e2c895e380b2154c55a54d6f3117e3767f Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Wed, 29 Nov 2023 09:40:11 +0000 Subject: [PATCH] Set date filter GA4 data attrs outside component - credit to @floehopper - this means more of the GA4 related data attributes for facets are now set in the relevant partial template, which makes the code easier to follow --- app/views/components/_date_filter.html.erb | 3 ++- app/views/finders/_date_facet.html.erb | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/components/_date_filter.html.erb b/app/views/components/_date_filter.html.erb index bb92e7ae62..d10be12d60 100644 --- a/app/views/components/_date_filter.html.erb +++ b/app/views/components/_date_filter.html.erb @@ -6,9 +6,10 @@ aria_controls_id ||= false date_errors_from ||= nil date_errors_to ||= nil + data_attributes ||= nil %> <% if key && name %> - <%= render "components/expander", { title: name, data_attributes: { "ga4-filter-parent": name } } do %> + <%= render "components/expander", { title: name, data_attributes: } do %>
<%= render "govuk_publishing_components/components/input", { label: { diff --git a/app/views/finders/_date_facet.html.erb b/app/views/finders/_date_facet.html.erb index 7137ba3478..da7a546095 100644 --- a/app/views/finders/_date_facet.html.erb +++ b/app/views/finders/_date_facet.html.erb @@ -1,12 +1,12 @@ - <%= - render "components/date_filter", { + <%= render "components/date_filter", { name: date_facet.name, key: date_facet.key, from_value: date_facet.user_supplied_from_date, to_value: date_facet.user_supplied_to_date, aria_controls_id: "js-search-results-info", date_errors_to: date_facet.error_message_to(@search_query), - date_errors_from: date_facet.error_message_from(@search_query) + date_errors_from: date_facet.error_message_from(@search_query), + data_attributes: { "ga4-filter-parent": date_facet.name } } %> \ No newline at end of file