mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:51:43 +08:00
FIX: Translated button title didn't work (#11872)
Follow-up to 6f13d2b039
This commit is contained in:
parent
9ae067164d
commit
5a6baa7c46
|
@ -31,9 +31,13 @@ export const ButtonClass = {
|
|||
buildAttributes() {
|
||||
const attrs = this.attrs;
|
||||
const attributes = {};
|
||||
let title = attrs.translatedTitle;
|
||||
|
||||
if (attrs.title) {
|
||||
const title = I18n.t(attrs.title, attrs.titleOptions);
|
||||
if (!title && attrs.title) {
|
||||
title = I18n.t(attrs.title, attrs.titleOptions);
|
||||
}
|
||||
|
||||
if (title) {
|
||||
attributes["aria-label"] = title;
|
||||
attributes.title = title;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ export default createWidget("post-edits-indicator", {
|
|||
|
||||
return this.attach("flat-button", {
|
||||
icon,
|
||||
title,
|
||||
translatedTitle: title,
|
||||
className,
|
||||
action: "onPostEditsIndicatorClick",
|
||||
translatedLabel: attrs.version > 1 ? attrs.version - 1 : "",
|
||||
|
|
|
@ -82,4 +82,17 @@ discourseModule("Integration | Component | Widget | button", function (hooks) {
|
|||
assert.equal(query("button span.d-button-label").innerText, "foo bar");
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("translatedTitle", {
|
||||
template: '{{mount-widget widget="button" args=args}}',
|
||||
|
||||
beforeEach() {
|
||||
this.set("args", { label: "topic.create", translatedTitle: "foo bar" });
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(query("button").title, "foo bar");
|
||||
assert.equal(query("button").ariaLabel, "foo bar");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user