From 21ed67ded23f9d9522b9ad72f5aae8640e0d8437 Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:37:38 +0000 Subject: [PATCH] Use component wrapper on reorderable list component --- CHANGELOG.md | 1 + .../components/_reorderable_list.html.erb | 8 +++++--- .../components/docs/reorderable_list.yml | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84034d5db6..c6832fbccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Support Welsh devolved nations component ([PR #4440](https://github.com/alphagov/govuk_publishing_components/pull/4440)) * Use component wrapper on previous and next component ([PR #4463](https://github.com/alphagov/govuk_publishing_components/pull/4463)) * Use component wrapper on related nav component ([PR #4466](https://github.com/alphagov/govuk_publishing_components/pull/4466)) +* Use component wrapper on reorderable list component ([PR #4474](https://github.com/alphagov/govuk_publishing_components/pull/4474)) ## 46.1.0 diff --git a/app/views/govuk_publishing_components/components/_reorderable_list.html.erb b/app/views/govuk_publishing_components/components/_reorderable_list.html.erb index 5e9932aa1c..ab31d417c3 100644 --- a/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +++ b/app/views/govuk_publishing_components/components/_reorderable_list.html.erb @@ -3,11 +3,13 @@ items ||= [] input_name ||= "ordering" - data_attributes ||= {} - data_attributes[:module] = "reorderable-list" + + component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) + component_helper.add_class("gem-c-reorderable-list") + component_helper.add_data_attribute({ module: "reorderable-list" }) %> -<%= tag.ol class: "gem-c-reorderable-list", data: data_attributes do %> +<%= tag.ol(**component_helper.all_attributes) do %> <% items.each_with_index do |item, index| %> <%= tag.li class: "gem-c-reorderable-list__item" do %> <%= tag.div class: "gem-c-reorderable-list__wrapper" do %> diff --git a/app/views/govuk_publishing_components/components/docs/reorderable_list.yml b/app/views/govuk_publishing_components/components/docs/reorderable_list.yml index e6457bcee7..1282a30150 100644 --- a/app/views/govuk_publishing_components/components/docs/reorderable_list.yml +++ b/app/views/govuk_publishing_components/components/docs/reorderable_list.yml @@ -17,6 +17,7 @@ body: | you'd receive a submission of `ordering[a]=1&ordering[b]=2`, which Rails can translate to `"ordering" => { "a" => "1", "b" => "2" }`. +uses_component_wrapper_helper: true accessibility_criteria: | Buttons in this component must: