Skip to content

Commit

Permalink
Set date filter GA4 data attrs outside component
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
andysellick committed Nov 29, 2023
1 parent a54e77a commit 4ea037e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/views/components/_date_filter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<div class="govuk-!-margin-bottom-0" id="<%= key %>">
<%= render "govuk_publishing_components/components/input", {
label: {
Expand Down
6 changes: 3 additions & 3 deletions app/views/finders/_date_facet.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<span data-ga4-change-category="update-filter text">
<%=
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 }
} %>
</span>

0 comments on commit 4ea037e

Please sign in to comment.