@@ -4,7 +4,7 @@ import { SLOT_NAME_FIRST } from '../constants/slots'
4
4
import { htmlOrText } from '../utils/html'
5
5
import { looseEqual } from '../utils/loose-equal'
6
6
import { makeModelMixin } from '../utils/model'
7
- import { sortKeys } from '../utils/object'
7
+ import { omit , pick , sortKeys } from '../utils/object'
8
8
import { makeProp , makePropsConfigurable } from '../utils/props'
9
9
import { BFormCheckbox } from '../components/form-checkbox/form-checkbox'
10
10
import { BFormRadio } from '../components/form-radio/form-radio'
@@ -18,6 +18,9 @@ import { normalizeSlotMixin } from './normalize-slot'
18
18
19
19
// --- Constants ---
20
20
21
+ // Attributes to pass down to checks/radios instead of applying them to the group
22
+ const PASS_DOWN_ATTRS = [ 'aria-describedby' , 'aria-labelledby' ]
23
+
21
24
const {
22
25
mixin : modelMixin ,
23
26
props : modelProps ,
@@ -63,6 +66,7 @@ export const formRadioCheckGroupMixin = Vue.extend({
63
66
formStateMixin ,
64
67
formCustomMixin
65
68
] ,
69
+ inheritAttrs : false ,
66
70
props,
67
71
data ( ) {
68
72
return {
@@ -75,7 +79,7 @@ export const formRadioCheckGroupMixin = Vue.extend({
75
79
} ,
76
80
8000
groupName ( ) {
77
81
// Checks/Radios tied to the same model must have the same name,
78
- // especially for ARIA accessibility.
82
+ // especially for ARIA accessibility
79
83
return this . name || this . safeId ( )
80
84
} ,
81
85
groupClasses ( ) {
@@ -111,6 +115,7 @@ export const formRadioCheckGroupMixin = Vue.extend({
111
115
} ,
112
116
render ( h ) {
113
117
const { isRadioGroup } = this
118
+ const attrs = pick ( this . $attrs , PASS_DOWN_ATTRS )
114
119
const optionComponent = isRadioGroup ? BFormRadio : BFormCheckbox
115
120
116
121
const $inputs = this . formOptions . map ( ( option , index ) => {
@@ -120,15 +125,16 @@ export const formRadioCheckGroupMixin = Vue.extend({
120
125
optionComponent ,
121
126
{
122
127
props : {
123
- id : this . safeId ( key ) ,
124
- value : option . value ,
125
128
// Individual radios or checks can be disabled in a group
126
- disabled : option . disabled || false
129
+ disabled : option . disabled || false ,
130
+ id : this . safeId ( key ) ,
131
+ value : option . value
127
132
// We don't need to include these, since the input's will know they are inside here
128
- // name: this.groupName,
129
133
// form: this.form || null,
134
+ // name: this.groupName,
130
135
// required: Boolean(this.name && this.required)
131
136
} ,
137
+ attrs,
132
138
key
133
139
} ,
134
140
[ h ( 'span' , { domProps : htmlOrText ( option . html , option . text ) } ) ]
@@ -140,12 +146,13 @@ export const formRadioCheckGroupMixin = Vue.extend({
140
146
{
141
147
class : [ this . groupClasses , 'bv-no-focus-ring' ] ,
142
148
attrs : {
149
+ ...omit ( this . $attrs , PASS_DOWN_ATTRS ) ,
150
+ 'aria-invalid' : this . computedAriaInvalid ,
151
+ 'aria-required' : this . required ? 'true' : null ,
143
152
id : this . safeId ( ) ,
144
153
role : isRadioGroup ? 'radiogroup' : 'group' ,
145
154
// Add `tabindex="-1"` to allow group to be focused if needed by screen readers
146
- tabindex : '-1' ,
147
- 'aria-required' : this . required ? 'true' : null ,
148
- 'aria-invalid' : this . computedAriaInvalid
155
+ tabindex : '-1'
149
156
}
150
157
} ,
151
158
[ this . normalizeSlot ( SLOT_NAME_FIRST ) , $inputs , this . normalizeSlot ( ) ]
0 commit comments