Commit 98b762cb authored by Doug Stull's avatar Doug Stull

Add option to pass options to emoji_icon

- we want to enable passing aria-hidden
  to turn off reading of the icon on screen
  readers
parent 6fb6be1a
......@@ -45,7 +45,7 @@ module Gitlab
end
# CSS sprite fallback takes precedence over image fallback
def gl_emoji_tag(name)
def gl_emoji_tag(name, options = {})
emoji_name = emojis_aliases[name] || name
emoji_info = emojis[emoji_name]
return unless emoji_info
......@@ -54,8 +54,9 @@ module Gitlab
name: emoji_name,
unicode_version: emoji_unicode_version(emoji_name)
}
options = { title: emoji_info['description'], data: data }.merge(options)
ActionController::Base.helpers.content_tag('gl-emoji', emoji_info['moji'], title: emoji_info['description'], data: data)
ActionController::Base.helpers.content_tag('gl-emoji', emoji_info['moji'], options)
end
private
......
# frozen_string_literal: true
require 'spec_helper'
describe EmojiHelper do
# include UploadHelpers
describe '#emoji_icon' do
let(:options) { {} }
let(:emoji_text) { 'rocket' }
let(:aria_hidden_option) { "aria-hidden=\"true\"" }
subject { helper.emoji_icon(emoji_text, options) }
it 'has no options' do
is_expected.to include('<gl-emoji',
"title=\"#{emoji_text}\"",
"data-name=\"#{emoji_text}\"",
"data-unicode-version=\"#{::Gitlab::Emoji.emoji_unicode_version(emoji_text)}\"")
is_expected.not_to include(aria_hidden_option)
end
context 'with aria-hidden option' do
let(:options) { { 'aria-hidden': true } }
it 'applies aria-hidden' do
is_expected.to include('<gl-emoji',
"title=\"#{emoji_text}\"",
"data-name=\"#{emoji_text}\"",
"data-unicode-version=\"#{::Gitlab::Emoji.emoji_unicode_version(emoji_text)}\"",
aria_hidden_option)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment