diff options
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
| -rw-r--r-- | addons/web/static/src/js/fields/relational_fields.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 432961bc0bf..c6db91778ec 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -3068,6 +3068,27 @@ var FieldRadio = FieldSelection.extend({ return true; }, + /** + * Returns the currently-checked radio button, or the first one if no radio + * button is checked. + * + * @override + */ + getFocusableElement: function () { + var checked = this.$("[checked='true']"); + return checked.length ? checked : this.$("[data-index='0']"); + }, + + /** + * Associates the 'for' attribute to the radiogroup, instead of the selected + * radio button. + * + * @param {string} id + */ + setIDForLabel: function (id) { + this.$el.attr('id', id); + }, + //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- @@ -3085,11 +3106,14 @@ var FieldRadio = FieldSelection.extend({ currentValue = this.value; } this.$el.empty(); + this.$el.attr('role', 'radiogroup') + .attr('aria-label', this.string); _.each(this.values, function (value, index) { self.$el.append(qweb.render('FieldRadio.button', { checked: value[0] === currentValue, id: self.unique_id + '_' + value[0], index: index, + name: self.unique_id, value: value, })); }); |
