diff --git a/app/views/components/_contents_list_with_body.html.erb b/app/views/components/_contents_list_with_body.html.erb
index b8659b4db..188ac6ade 100644
--- a/app/views/components/_contents_list_with_body.html.erb
+++ b/app/views/components/_contents_list_with_body.html.erb
@@ -3,9 +3,15 @@
<% unless block.empty? %>
<%
contents ||= []
- sticky_attr = ' data-module="sticky-element-container"'.html_safe if contents.any?
+ sticky_attr = "sticky-element-container" if contents.any?
%>
-
>
+ <%= tag.div(
+ id: "contents",
+ class: "app-c-contents-list-with-body",
+ data: {
+ module: sticky_attr,
+ },
+ ) do %>
<% if contents.any? %>
<%= render 'govuk_publishing_components/components/contents_list', contents: contents %>
@@ -19,5 +25,5 @@
<% end %>
-
+ <% end %>
<% end %>
diff --git a/app/views/components/_important_metadata.html.erb b/app/views/components/_important_metadata.html.erb
index 2d6ded5c5..1ffdc9f04 100644
--- a/app/views/components/_important_metadata.html.erb
+++ b/app/views/components/_important_metadata.html.erb
@@ -3,7 +3,7 @@
title = local_assigns[:title]
items = local_assigns[:items] || {}
items = items.reject { |k,v| v.nil? }
- items = items.merge(items) { |k,v| Array(v).join(", ").html_safe }
+ items = items.merge(items) { |k,v| Array(v).join(", ") }
margin_bottom_class = " app-c-important-metadata--bottom-margin" unless local_assigns[:margin_bottom]
-%>
<% if items.any? %>
diff --git a/app/views/components/docs/contents_list_with_body.yml b/app/views/components/docs/contents_list_with_body.yml
index 9e1a76c06..9094b27e0 100644
--- a/app/views/components/docs/contents_list_with_body.yml
+++ b/app/views/components/docs/contents_list_with_body.yml
@@ -79,10 +79,10 @@ examples: