Can’t use kwargs on legends
Closed this issue · 1 comments
paulrobertlloyd commented
With the following template
<%= f.govuk_fieldset
legend: {
text: 'Question title',
size: 'xl',
tag: 'h1',
a: 'b'
},
caption: {
text: 'Section title',
a: 'b'
}
do %>
…
<% end %>
the following HTML is output:
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
<h1 class="govuk-fieldset__heading">
<span class="govuk-caption-m" a="b">Section title</span>
Question title
</h1>
</legend>
…
</fieldset>
Note how a=b
does not appear on the <legend>
element, as suggested in the documentation, and as shown to work as an option for caption
.
I’m wondering if @html_attributes = kwargs
should appear within the clause when Hash
(but that’s just a wild and uninformed stab in the dark).
peteryates commented
Yeah, definitely a bug here. You identified the line at fault but the reason is that the custom attributes are in the legend
hash and not in kwargs
. This class is a bit out of step with its siblings due to the way it used to be structured, I'll bring it inline and add some tests on this behaviour. Thanks for reporting 👍