-
Notifications
You must be signed in to change notification settings - Fork 21
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
Standalone labels #514
Standalone labels #514
Conversation
✅ Deploy Preview for govuk-form-builder ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This simply exposes GOVUKDesignSystemFormBuilder::Elements::Label via a new `#govuk_label` method on the builder object. It is intended to be used on occasions where the label isn't wanted immediately above the input, such as in a table. Fixes #480
This is quite an advanced use which will stretch the Design System to the limit. HTML has long-supported placing labels far from the corresponding input, even outside the form altogether. The risk here is that error messages now will be placed by the input, which has a strong likelihood of breaking layouts. Still, I'm sure some people will find a use for this. Fixes #477
58dd55e
to
298d836
Compare
subject { builder.send(*args, **kwargs) } | ||
|
||
specify 'renders a label with the right custom text' do | ||
expect(subject).to have_tag('label', text: custom_label_text, with: { class: 'govuk-label' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding a test for the for
attribute too, given that this will be needed to link the label to the input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this, but yeah it is. Will add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
This PR exposes
GOVUKDesignSystemFormBuilder::Elements::Label
directly via#govuk_label
. It's intended to allow authors to place the label somewhere other than immediately above the input.Its usage isn't covered by the design system so comes with the risk that the error message will still be rendered next to the input which will likely break layouts when used in confined spaces (i.e., table cells)
The regular label arguments will still work so authors can customise the label's: