diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2017-04-24 19:55:46 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2017-04-24 19:55:46 +0000 |
commit | 22c88c675df13d918be1f4f681dbca47cb263bcb (patch) | |
tree | 3c8fc59deead757cb083d38a566ee56f40b3a4f6 | |
parent | 375746d6fc308dc16875750bc9342196166d28a6 (diff) | |
parent | f0a164a6d58fe8fe1711a7afbd698a5c2b546a1e (diff) | |
download | gitlab-ce-22c88c675df13d918be1f4f681dbca47cb263bcb.tar.gz |
Merge branch 'add-aria-to-icon' into 'master'
Add aria to icon
See merge request !10670
-rw-r--r-- | app/helpers/icons_helper.rb | 5 | ||||
-rw-r--r-- | changelogs/unreleased/add-aria-to-icon.yml | 4 | ||||
-rw-r--r-- | spec/helpers/icons_helper_spec.rb | 15 |
3 files changed, 24 insertions, 0 deletions
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index ab3ef454e1c..55fa81e95ef 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -7,6 +7,11 @@ module IconsHelper # font-awesome-rails gem, but should we ever use a different icon pack in the # future we won't have to change hundreds of method calls. def icon(names, options = {}) + if (options.keys & %w[aria-hidden aria-label]).empty? + # Add `aria-hidden` if there are no aria's set + options['aria-hidden'] = true + end + options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options) end diff --git a/changelogs/unreleased/add-aria-to-icon.yml b/changelogs/unreleased/add-aria-to-icon.yml new file mode 100644 index 00000000000..fd6a25784c6 --- /dev/null +++ b/changelogs/unreleased/add-aria-to-icon.yml @@ -0,0 +1,4 @@ +--- +title: Fixes an issue preventing screen readers from reading some icons +merge_request: +author: diff --git a/spec/helpers/icons_helper_spec.rb b/spec/helpers/icons_helper_spec.rb index c052981fe73..91c8faea7fd 100644 --- a/spec/helpers/icons_helper_spec.rb +++ b/spec/helpers/icons_helper_spec.rb @@ -1,6 +1,21 @@ require 'spec_helper' describe IconsHelper do + describe 'icon' do + it 'returns aria-hidden by default' do + star = icon('star') + + expect(star['aria-hidden']).to eq 'aria-hidden' + end + + it 'does not return aria-hidden if aria-label is set' do + up = icon('up', 'aria-label' => 'up') + + expect(up['aria-hidden']).to be_nil + expect(up['aria-label']).to eq 'aria-label' + end + end + describe 'file_type_icon_class' do it 'returns folder class' do expect(file_type_icon_class('folder', 0, 'folder_name')).to eq 'folder' |