Skip to content
This repository was archived by the owner on May 5, 2020. It is now read-only.

Commit

Permalink
Accessibility fixes
Browse files Browse the repository at this point in the history
Based on GOV.UK design system, and constrained by the fact that this gem is old and not using the latest version of the UI components, we've introduced a couple minor improvements:

* Replace the role `group` with role `alert` in the `div#error-summary`.
* Change `h1` to `h2` in the heading of the error summary.

Also, we've bumped some gem dependencies to fix most of the vuln alerts, but in a conservative way as this gem is suppose to be used in the context of a full app that will be in control of actually specifying the versions of the dependencies they want to use. I don't want to "force" specific versions in this gem.

A new version of the gem will be built and published with these changes.
  • Loading branch information
zheileman committed Jan 24, 2019
1 parent 7c6178b commit 8900cd8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 36 deletions.
65 changes: 35 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
govuk_elements_form_builder (1.1.0)
govuk_elements_form_builder (1.2.0)
govuk_elements_rails (>= 3.0.0)
govuk_frontend_toolkit (>= 6.0.0)
rails (>= 4.2)
Expand Down Expand Up @@ -50,20 +50,21 @@ GEM
codeclimate-test-reporter (0.6.0)
simplecov (>= 0.7.1, < 1.0.0)
coderay (1.1.1)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.4)
crass (1.0.4)
diff-lcs (1.2.5)
docile (1.1.5)
erubis (2.7.0)
ffi (1.9.10)
formatador (0.2.5)
globalid (0.4.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
govuk_elements_rails (3.0.2)
govuk_frontend_toolkit (>= 5.2.0)
govuk_elements_rails (3.1.3)
govuk_frontend_toolkit (>= 6.0.2)
rails (>= 4.1.0)
sass (>= 3.2.0)
govuk_frontend_toolkit (6.0.1)
rails (>= 3.1.0)
govuk_frontend_toolkit (8.1.0)
railties (>= 3.1.0)
sass (>= 3.2.0)
guard (2.13.0)
formatador (>= 0.2.4)
Expand All @@ -80,33 +81,33 @@ GEM
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
htmlbeautifier (1.1.1)
i18n (0.7.0)
json (1.8.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (1.8.6)
listen (3.0.6)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
loofah (2.0.3)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.10)
mail (2.6.5)
mime-types (>= 1.16, < 4)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.0.0)
minitest (5.8.4)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
nenv (0.3.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
notiffany (0.0.8)
nenv (~> 0.1)
shellany (~> 0.0)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
rack (1.6.11)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.6)
Expand All @@ -122,12 +123,12 @@ GEM
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (4.2.6)
actionpack (= 4.2.6)
activesupport (= 4.2.6)
Expand Down Expand Up @@ -161,25 +162,29 @@ GEM
rspec-mocks (~> 3.2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
sass (3.4.23)
sass (3.7.3)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
shellany (0.0.1)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
sprockets (3.7.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)

PLATFORMS
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/govuk_elements_errors_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def self.children_with_errors object
def self.error_summary_div &block
content_tag(:div,
class: 'error-summary',
role: 'group',
role: 'alert',
aria: {
labelledby: 'error-summary-heading'
},
Expand All @@ -98,7 +98,7 @@ def self.error_summary_div &block
end

def self.error_summary_heading text
content_tag :h1,
content_tag :h2,
text,
id: 'error-summary-heading',
class: 'heading-medium error-summary-heading'
Expand Down
Empty file.
16 changes: 13 additions & 3 deletions spec/helpers/govuk_elements_errors_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,19 @@
expect(output).to_not be_nil
end

it 'expects the `div.error-summary` to have specific attributes' do
expect(
pretty_output
).to have_tag('div.error-summary', with: {
role: 'alert',
tabindex: '-1',
'aria-labelledby': 'error-summary-heading',
})
end

it 'outputs title and description' do
expect(pretty_output).to have_tag('div.error-summary') do
with_tag 'h1#error-summary-heading', summary_title
with_tag 'h2#error-summary-heading', summary_title
with_tag 'p', summary_description
end
end
Expand Down Expand Up @@ -100,7 +110,7 @@

it 'outputs title and description' do
expect(pretty_output).to have_tag('div.error-summary') do
with_tag 'h1#error-summary-heading', summary_title
with_tag 'h2#error-summary-heading', summary_title
with_tag 'p', summary_description
end
end
Expand Down Expand Up @@ -143,7 +153,7 @@

it 'outputs title and description' do
expect(pretty_output).to have_tag('div.error-summary') do
with_tag 'h1#error-summary-heading', summary_title
with_tag 'h2#error-summary-heading', summary_title
with_tag 'p', summary_description
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/govuk_elements_form_builder/form_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestHelper < ActionView::Base; end
include TranslationHelper

it "should have a version" do
expect(GovukElementsFormBuilder::VERSION).to eq("1.1.0")
expect(GovukElementsFormBuilder::VERSION).to eq("1.2.0")
end

let(:helper) { TestHelper.new }
Expand Down

0 comments on commit 8900cd8

Please sign in to comment.