diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.js b/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.js index 1378ac0d604..2f0eea11a2d 100644 --- a/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.js +++ b/app/assets/javascripts/discourse/tests/integration/helpers/emoji-test.js @@ -11,4 +11,13 @@ module("Integration | Helper | emoji", function (hooks) { await render(hbs`{{emoji "tada"}}`); assert.ok(exists(`.emoji[title="tada"]`)); }); + + test("it renders custom title", async function (assert) { + const title = "custom title"; + this.set("title", title); + + await render(hbs`{{emoji "tada" title=this.title}}`); + + assert.ok(exists(`.emoji[title="${title}"]`)); + }); }); diff --git a/app/assets/javascripts/pretty-text/addon/emoji.js b/app/assets/javascripts/pretty-text/addon/emoji.js index e8f2a29f067..2c2028e5668 100644 --- a/app/assets/javascripts/pretty-text/addon/emoji.js +++ b/app/assets/javascripts/pretty-text/addon/emoji.js @@ -92,12 +92,13 @@ export function performEmojiUnescape(string, opts) { (isEmoticon || hasEndingColon || isUnicodeEmoticon) && isReplacableInlineEmoji(string, index, opts.inlineEmoji); + const title = opts.title ?? emojiVal; return url && isReplacable ? `` + }alt='${title}' class='${classes}'>` : m; };