Skip to content

Commit

Permalink
[common] Adjust metric spinner component for screen readers
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaSvinareva committed Feb 26, 2024
1 parent a76c0be commit 14464d1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
15 changes: 13 additions & 2 deletions apps/common/main/lib/component/MetricSpinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ define([
rendered : false,

template :
'<input type="text" class="form-control" spellcheck="false" data-hint="<%= dataHint %>" data-hint-direction="<%= dataHintDirection %>" data-hint-offset="<%= dataHintOffset %>">' +
'<input type="text" class="form-control" spellcheck="false" role="spinbutton" data-hint="<%= dataHint %>" data-hint-direction="<%= dataHintDirection %>" data-hint-offset="<%= dataHintOffset %>">' +
'<div class="spinner-buttons">' +
'<button type="button" class="spinner-up"><i class="arrow"></i></button>' +
'<button type="button" class="spinner-down"><i class="arrow"></i></button>' +
Expand Down Expand Up @@ -210,6 +210,12 @@ define([
if (this.options.tabindex != undefined)
this.$input.attr('tabindex', this.options.tabindex);

this.$input.attr('aria-valuemin', this.options.minValue);
this.$input.attr('aria-valuemax', this.options.maxValue);

if (this.options.ariaLabel)
this.$input.attr('aria-label', this.options.ariaLabel);

return this;
},

Expand Down Expand Up @@ -241,10 +247,12 @@ define([

setMinValue: function(unit){
this.options.minValue = unit;
if (this.$input) this.$input.attr('aria-valuemin', unit);
},

setMaxValue: function(unit){
this.options.maxValue = unit;
if (this.$input) this.$input.attr('aria-valuemax', unit);
},

setStep: function(step){
Expand Down Expand Up @@ -272,7 +280,10 @@ define([
},

setRawValue: function (value) {
if (this.$input) this.$input.val(value);
if (this.$input) {
this.$input.val(value);
this.$input.attr('aria-valuetext', value);
}
},

getRawValue: function () {
Expand Down
18 changes: 12 additions & 6 deletions apps/documenteditor/main/app/view/ParagraphSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ define([
disabled: this._locked,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
dataHintOffset: 'big',
ariaLabel: this.strLineHeight
});
this.lockedControls.push(this.numLineHeight);

Expand All @@ -154,7 +155,8 @@ define([
disabled: this._locked,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
dataHintOffset: 'big',
ariaLabel: this.strParagraphSpacing + ' ' + this.strSpacingBefore
});
this.spinners.push(this.numSpacingBefore);
this.lockedControls.push(this.numSpacingBefore);
Expand All @@ -172,7 +174,8 @@ define([
disabled: this._locked,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
dataHintOffset: 'big',
ariaLabel: this.strParagraphSpacing + ' ' + this.strSpacingAfter
});
this.spinners.push(this.numSpacingAfter);
this.lockedControls.push(this.numSpacingAfter);
Expand Down Expand Up @@ -211,7 +214,8 @@ define([
disabled: this._locked,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
dataHintOffset: 'big',
ariaLabel: this.strIndent + ' ' + this.strIndentsLeftText
});
this.spinners.push(this.numIndentsLeft);
this.lockedControls.push(this.numIndentsLeft);
Expand All @@ -228,7 +232,8 @@ define([
disabled: this._locked,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
dataHintOffset: 'big',
ariaLabel: this.strIndent + ' ' + this.strIndentsRightText
});
this.spinners.push(this.numIndentsRight);
this.lockedControls.push(this.numIndentsRight);
Expand Down Expand Up @@ -261,7 +266,8 @@ define([
disabled: this._locked,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
dataHintOffset: 'big',
ariaLabel: this.strIndent + ' ' + this.strIndentsSpecial
});
this.spinners.push(this.numSpecialBy);
this.lockedControls.push(this.numSpecialBy);
Expand Down

0 comments on commit 14464d1

Please sign in to comment.