Add valuemin and valuemax aria properties for number fields (#2850)

This commit is contained in:
Sam El-Husseini
2019-08-16 18:41:05 -07:00
committed by GitHub
parent 63f55da379
commit c99734b8f9
2 changed files with 22 additions and 1 deletions

View File

@@ -139,4 +139,25 @@ Blockly.FieldNumber.prototype.doClassValidation_ = function(opt_newValue) {
return n;
};
/**
* Create the number input editor widget.
* @return {!HTMLInputElement} The newly created number input editor.
* @protected
* @override
*/
Blockly.FieldNumber.prototype.widgetCreate_ = function() {
var htmlInput = Blockly.FieldNumber.superClass_.widgetCreate_.call(this);
// Set the accessibility state
if (this.min_ > -Infinity) {
Blockly.utils.aria.setState(htmlInput,
Blockly.utils.aria.State.VALUEMIN, this.min_);
}
if (this.max_ < Infinity) {
Blockly.utils.aria.setState(htmlInput,
Blockly.utils.aria.State.VALUEMAX, this.max_);
}
return htmlInput;
};
Blockly.fieldRegistry.register('field_number', Blockly.FieldNumber);

View File

@@ -249,7 +249,7 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
/**
* Create the text input editor widget.
* @return {!HTMLInputElement} The newly created text input editor.
* @private
* @protected
*/
Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
var div = Blockly.WidgetDiv.DIV;