Skip to content

Commit

Permalink
feat ariatemplates#1775 new ariaLive parameter on the aria:ErrorList …
Browse files Browse the repository at this point in the history
…widget

This new ariaLive parameter allows to specify whether role="alert" and
aria-live="assertive" are included (true) or omitted (false) on the
container element of the aria:ErrorList widget (defaults to true, only
used if waiAria is true)

close ariatemplates#1775
PTR 12238923
  • Loading branch information
divdavem committed Sep 13, 2017
1 parent c1cb9de commit ccdcae1
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/aria/widgets/CfgBeans.js
Expand Up @@ -1656,6 +1656,11 @@ module.exports = Aria.beanDefinitions({
$type : "json:Boolean",
$description : "Set this bindable property to true to put the focus on the first item. As soon as the focus has been set, the property will be set back to false.",
$default : false
},
"ariaLive" : {
$type : "json:Boolean",
$description : "Specifies whether role=alert and aria-live=assertive are included (true) or omitted (false) on the container element (defaults to true, only used if waiAria is true)",
$default : true
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/aria/widgets/errorlist/ErrorList.js
Expand Up @@ -44,7 +44,7 @@ module.exports = Aria.classDefinition({
divCfg.margins = "0 0 0 0";
divCfg.id = cfg.id + "_div";

if (cfg.waiAria) {
if (cfg.waiAria && cfg.ariaLive) {
this._extraAttributes = ' role="alert" aria-live="assertive" ';
}

Expand Down
11 changes: 9 additions & 2 deletions test/aria/widgets/wai/errorlist/binding/ErrorListBindingCtrl.js
Expand Up @@ -12,7 +12,8 @@ Aria.classDefinition({
phoneNumber : "",
email : "",
errorMessages : [],
focus: false
focus: false,
focusOnError: true
};
this.myDataUtil = aria.utils.Data;
this.validators = [];
Expand All @@ -30,6 +31,12 @@ Aria.classDefinition({
$publicInterfaceName : "test.aria.widgets.wai.errorlist.binding.IErrorListBindingCtrl",
init : function (arg, cb) {
var validatorPkg = aria.utils.validators;
if ("ariaLive" in arg) {
this.json.setValue(this._data, "ariaLive", arg.ariaLive);
}
if ("focusOnError" in arg) {
this.json.setValue(this._data, "focusOnError", arg.focusOnError);
}

var firstNameValidator = new validatorPkg.Mandatory("The first name is a required field using a mandatory validator.");
this.myDataUtil.setValidatorProperties(firstNameValidator, null, "onblur");
Expand Down Expand Up @@ -58,7 +65,7 @@ Aria.classDefinition({
var messages = {};
this.myDataUtil.validateModel(this._data, messages);
this.json.setValue(this._data, "errorMessages", messages.listOfMessages);
if (messages.listOfMessages && messages.listOfMessages.length) {
if (messages.listOfMessages && messages.listOfMessages.length && this._data.focusOnError) {
this.json.setValue(this._data, "focus", true);
}
}
Expand Down
Expand Up @@ -34,8 +34,6 @@ module.exports = Aria.classDefinition({

// ------------------------------------ template data & test environment

var type = dataUtils.TYPE_CONFIRMATION;

this.setTestEnv({
template : "test.aria.widgets.wai.errorlist.binding.ErrorListBindingTpl",
moduleCtrl : {
Expand Down
Expand Up @@ -11,6 +11,7 @@
margins: "10 1 10 1",
title: "Error",
filterTypes: ['E'],
ariaLive: data.ariaLive,
bind: {
messages: {
to: "errorMessages",
Expand Down
@@ -0,0 +1,86 @@
/*
* Copyright 2013 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var Aria = require("ariatemplates/Aria");

var dataUtils = require("ariatemplates/utils/Data");

var JawsTestCase = require("ariatemplates/jsunit/JawsTestCase");
var AppEnvironment = require("ariatemplates/core/AppEnvironment");

require("ariatemplates/utils/validators/CfgBeans"); // just to make sure it is correctly defined
require("ariatemplates/widgets/errorlist/ErrorListTemplate.tpl"); // just to be sure the template is loaded when the test is run, since it depends on its (DOM) content

module.exports = Aria.classDefinition({
$classpath : "test.aria.widgets.wai.errorlist.binding.ErrorListNoAriaLiveJawsTestCase",
$extends : JawsTestCase,

$constructor : function() {
// ---------------------------------------------------------------------

this.$JawsTestCase.constructor.call(this);

// ------------------------------------ template data & test environment

this.setTestEnv({
template : "test.aria.widgets.wai.errorlist.binding.ErrorListBindingTpl",
moduleCtrl : {
classpath : 'test.aria.widgets.wai.errorlist.binding.ErrorListBindingCtrl',
initArgs: {
ariaLive : false,
focusOnError : false
}
}
});

this.noiseRegExps.push(/\\$/, /^Email Address:$/i);
},

$prototype : {
run : function () {
AppEnvironment.setEnvironment({
appSettings: {
waiAria: true
}
}, {
scope: this,
fn: this.$JawsTestCase.run
});
},

runTemplateTest : function () {
this.synEvent.execute([
["click", this.getInputField("email")],
["pause", 1000],
["type", null, "[down][down]"],
["pause", 1000],
["type", null, "[space]"],
["pause", 3000] // check that nothing is said when errors are displayed
], {
fn: function () {
this.assertJawsHistoryEquals(
"Email Address: Edit\nType in text.\nSubmit Button",
this.end,
function filter(content) {
content = content.replace(/(Submit)\n(Button)/gi, '$1 $2');
return content;
}
);
},
scope: this
});
}
}
});

0 comments on commit ccdcae1

Please sign in to comment.