UX: Don't default title to label text for buttons.

This commit is contained in:
Guo Xiang Tan 2018-03-28 09:03:35 +08:00
parent 90c0198a57
commit 08d68e846c
2 changed files with 13 additions and 5 deletions

View File

@ -6,7 +6,7 @@ export default Ember.Component.extend({
tagName: 'button',
classNameBindings: [':btn', 'noText', 'btnType'],
attributeBindings: ['disabled', 'translatedTitle:title', 'tabindex'],
attributeBindings: ['disabled', 'translatedTitle:title', 'ariaLabel:aria-label', 'tabindex'],
btnIcon: Ember.computed.notEmpty('icon'),
@ -23,7 +23,7 @@ export default Ember.Component.extend({
@computed("title")
translatedTitle(title) {
return title ? I18n.t(title) : this.get('translatedLabel');
if (title) return I18n.t(title);
},
@computed("label")
@ -31,6 +31,11 @@ export default Ember.Component.extend({
if (label) return I18n.t(label);
},
@computed("translatedTitle", "translatedLabel")
ariaLabel(translatedTitle, translatedLabel) {
return translatedTitle ? translatedTitle : translatedLabel;
},
click() {
this.sendAction("action", this.get("actionParam"));
return false;

View File

@ -32,11 +32,14 @@ export const ButtonClass = {
let title;
if (attrs.title) {
title = I18n.t(attrs.title, attrs.titleOptions);
} else if (attrs.label) {
title = I18n.t(attrs.label, attrs.labelOptions);
}
const attributes = { "aria-label": title, title };
let label;
if (attrs.label) {
label = I18n.t(attrs.label, attrs.labelOptions);
}
const attributes = { "aria-label": label, title };
if (attrs.disabled) { attributes.disabled = "true"; }
if (attrs.data) {