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

Propagate value to hint element in FieldsetCheckBox #211

Merged
merged 3 commits into from
Oct 28, 2020
Merged

Propagate value to hint element in FieldsetCheckBox #211

merged 3 commits into from
Oct 28, 2020

Conversation

zheileman
Copy link
Contributor

The value was missing from the hint_options hash, and the consequence was (because a nil value) the fallback to the hint text of the fieldset, when declaring individual checkboxes inside a govuk_check_boxes_fieldset (for example if one of the check boxes has to reveal a text area)

The code causing the issue was (it was entering in the second branching due to value being nil):

def schema_path
  if @value.present?
    [@object_name, "#{@attribute_name}_options", @value]
  else
    [@object_name, @attribute_name]
  end
end

Example before

Screenshot 2020-10-26 at 10 59 52

Example after

Screenshot 2020-10-27 at 11 35 26

If any of the individual check boxes had a hint text declared in the locales, it will show as expected:
Screenshot 2020-10-27 at 11 36 15

The value was missing from the `hint_options` hash, and the consequence was (because a `nil` value) the fallback to the hint text of the fieldset, when declaring individual checkboxes inside a `govuk_check_boxes_fieldset` (for example if one of the check boxes has to reveal a text area)

The code causing the issue was (it was entering in the second branching due to value being `nil`):

```ruby
def schema_path
        if @value.present?
          [@object_name, "#{@attribute_name}_options", @value]
        else
          [@object_name, @attribute_name]
        end
      end
```
@peteryates
Copy link
Member

Great, thanks for this. I definitely think a spec or two to cover this is a good idea.

@zheileman
Copy link
Contributor Author

zheileman commented Oct 27, 2020

@peteryates I tried to add an example to the guide, but for some reason couldn't get it to work this time. I've upgraded my system recently so I think some dependency is now broken, I got this:

cd guide; npm ci --silent
added 1 packages in 0.637s
cd guide; bundle exec nanoc
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'

Captain! We’ve been hit!

LoadError: dlopen(/Users/jesuslaiz/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Users/jesuslaiz/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle
  Reason: image not found - /Users/jesuslaiz/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle

We have smoke tests with markup fixtures that raised this issue when trying to use the latest version of the gem (in one of our projects we were still in the 1.2.x branch) 👍

@peteryates
Copy link
Member

Ah. your Ruby is probably compiled against the older library. I expect reinstalling Ruby 2.6.5 will fix that for you.

peteryates and others added 2 commits October 27, 2020 16:39
There was already an example but the existing one was simpler, using the `govuk_collection_check_boxes`.

This new example focus more in the `govuk_check_boxes_fieldset` declaring individual check boxes and one with a revealing text box. Each of the check boxes have independent labels and hints localised.
Copy link
Member

@peteryates peteryates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant, thank you 🧟‍♂️

@zheileman zheileman merged commit 1a5daea into x-govuk:master Oct 28, 2020
@zheileman zheileman deleted the fix-checkbox-localisation branch October 28, 2020 13:07
zheileman added a commit to ministryofjustice/c100-application that referenced this pull request Oct 28, 2020
A new version of the gem that introduces the fix for the check boxes hint has been released and we can start using it.

https://github.com/DFE-Digital/govuk_design_system_formbuilder/releases/tag/v2.1.2

PR with the fix and more details:
x-govuk/govuk-form-builder#211
@cpjmcquillan
Copy link
Collaborator

@peteryates I believe there is a similar issue with govuk_collection_check_boxes adding the localised hint text into the generated fieldset if it isn't provided rather than respecting something blank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants