Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can’t use kwargs on legends #216

Closed
paulrobertlloyd opened this issue Nov 4, 2020 · 1 comment
Closed

Can’t use kwargs on legends #216

paulrobertlloyd opened this issue Nov 4, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@paulrobertlloyd
Copy link
Contributor

paulrobertlloyd commented Nov 4, 2020

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.

https://github.com/DFE-Digital/govuk_design_system_formbuilder/blob/d269218348fd976af8f05850664cd38699a22370/lib/govuk_design_system_formbuilder/elements/legend.rb#L7-L28

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
Copy link
Member

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants