Skip to content

Commit

Permalink
fix #1765 click events on aria:RadioButton did not bubble
Browse files Browse the repository at this point in the history
PTR 13434480
  • Loading branch information
divdavem committed May 31, 2017
1 parent ac81412 commit 0cb3e6f
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/aria/widgets/form/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ var ariaWidgetsFormCheckBox = require("./CheckBox");
this._setRadioValue();
this._focus();
if (event.target.tagName.toLowerCase() != "input") {
event.preventDefault(true);
event.preventDefault(false);
}
},

Expand Down
102 changes: 102 additions & 0 deletions test/aria/widgets/form/radiobutton/clickBubble/RadioButton.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright 2017 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.
*/

{Template {
$classpath:"test.aria.widgets.form.radiobutton.clickBubble.RadioButton",
$css: ["test.aria.widgets.form.radiobutton.clickBubble.RadioButtonStyle"],
$hasScript: true
}}
{macro main()}
<table class="myTable">
<tbody>
<tr>
<td colspan="2" class="noborder">Choose your option,
{@aria:Text {
bind: {
text: {
to: "clicks",
inside: data
}
}
} /} detected clicks
</td>
<th colspan="2" class="large">Column 1</th>
<th colspan="2" class="large">Column 2</th>
</tr>
<tr>
<td class="large">Line 1</td>
<th class="large">Info 1-2</th>
<td>Value 1</td>
<td class="center" {on click {fn: 'selectProposal', args: ['1']} /}>
{@aria:RadioButton {
id : "rb1",
keyValue: "v1",
bind : {
value : {
inside : data,
to : "value"
}
}
}/}
</td>
<td>Value 2</td>
<td class="center" {on click {fn: 'selectProposal', args: ['2']} /}>
{@aria:RadioButton {
id : "rb2",
keyValue: "v2",
bind : {
value : {
inside : data,
to : "value"
}
}
}/}
</td>
</tr>
<tr>
<td class="large">Line 2</td>
<th class="large">Info 3-4</t>
<td>Value 3</td>
<td class="center" {on click {fn: 'selectProposal', args: ['3']} /}>
{@aria:RadioButton {
id : "rb3",
keyValue: "v3",
bind : {
value : {
inside : data,
to : "value"
}
}
}/}
</td>
<td>Value 4</td>
<td class="center" {on click {fn: 'selectProposal', args: ['4']} /}>
{@aria:RadioButton {
id : "rb4",
keyValue: "v4",
bind : {
value : {
inside : data,
to : "value"
}
}
}/}
</td>
</tr>
</tbody>
</table>

{/macro}
{/Template}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2017 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.
*/

Aria.tplScriptDefinition({
$classpath : "test.aria.widgets.form.radiobutton.clickBubble.RadioButtonScript",
$prototype : {
selectProposal: function (unused, args) {
var clicks = this.data.clicks || 0;
this.$json.setValue(this.data, "clicks", clicks + 1);
this.$json.setValue(this.data, "value", "v" + args[0]);
this.$focus("rb" + args[0]);
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2017 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.
*/

{CSSTemplate {
$classpath:"test.aria.widgets.form.radiobutton.clickBubble.RadioButtonStyle"
}}

{macro main()}
table.myTable {
border-collapse: collapse;
margin: 10px;
}
table.myTable th {
font-weight: normal;
background-color: lightgray;
}
table.myTable td, table.myTable th {
border: 1px solid gray;
padding: 5px;
}
table.myTable td.noborder {
border: none;
}
td.large, th.large {
width: 150px;
}
td.center {
text-align: center;
}
{/macro}

{/CSSTemplate}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2017 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.
*/

Aria.classDefinition({
$classpath : "test.aria.widgets.form.radiobutton.clickBubble.RadioButtonTestCase",
$extends : "aria.jsunit.TemplateTestCase",
$dependencies : ["aria.utils.Dom"],
$constructor : function () {
this.$TemplateTestCase.constructor.call(this);
this.data = {
clicks : 0
};
this.setTestEnv({
template : "test.aria.widgets.form.radiobutton.clickBubble.RadioButton",
data : this.data
});
},
$prototype : {
runTemplateTest : function () {
var rb3 = this.getElementById("rb3");
this.synEvent.click(rb3, {
fn: this.afterClick,
scope: this
});
},

afterClick : function () {
this.waitFor({
condition: function () {
return this.data.clicks === 1;
},
callback: this.end
});
}
}
});

0 comments on commit 0cb3e6f

Please sign in to comment.