Skip to content

Commit

Permalink
Stop setting id on fieldsets
Browse files Browse the repository at this point in the history
Now that the fieldset component uses the ComponentWrapperHelper, `id` should be handed by that instead of being explicitly called out.

This will result in `id` no longer being set on the fieldset, but instead on the parent. Jump links, the original usage for `id` will be unaffected, but any applications using `id` for other reasons (such as tests) may need to be updated.
  • Loading branch information
dnkrj committed Nov 29, 2024
1 parent 7bd137c commit 17175a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* **BREAKING** Stop setting `id` on fieldsets ([PR #4454](https://github.com/alphagov/govuk_publishing_components/pull/4454))

## 45.10.0

* Add 'toggle' module to each expandable region in metadata component ([PR #4397](https://github.com/alphagov/govuk_publishing_components/pull/4397))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
heading_size = false unless shared_helper.valid_heading_size?(heading_size)
error_message ||= nil
error_id ||= nil
id ||= nil

if error_message
error_id = "error-#{SecureRandom.hex(4)}" unless error_id
Expand All @@ -27,7 +26,7 @@
legend_classes << "govuk-fieldset__legend--#{heading_size}" if heading_size
%>
<%= tag.div(**component_helper.all_attributes) do %>
<%= tag.fieldset class: fieldset_classes, aria: { describedby: describedby }, role: role, id: id do %>
<%= tag.fieldset class: fieldset_classes, aria: { describedby: describedby }, role: role do %>
<% if heading_level %>
<%= tag.legend class: legend_classes do %>
<%= content_tag(
Expand Down
10 changes: 0 additions & 10 deletions spec/components/fieldset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ def component_name
assert_select ".gem-c-fieldset", text: /Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel ad neque, maxime est ea laudantium totam fuga!/
end

it "renders a fieldset with an id" do
render_component(
legend_text: "Do you have a passport?",
id: "passports",
text: "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel ad neque, maxime est ea laudantium totam fuga!",
)

assert_select ".govuk-fieldset#passports"
end

it "renders a fieldset with the legend as heading" do
render_component(
legend_text: "Do you have a passport?",
Expand Down

0 comments on commit 17175a7

Please sign in to comment.