Skip to content

Commit bd67da0

Browse files
authored
fix(b-dropdown): only apply heading role to header when not a header tag (#6274)
1 parent 026b3f9 commit bd67da0

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/components/dropdown/dropdown-group.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Vue, mergeData } from '../../vue'
22
import { NAME_DROPDOWN_GROUP } from '../../constants/components'
33
import { PROP_TYPE_ARRAY_OBJECT_STRING, PROP_TYPE_STRING } from '../../constants/props'
44
import { SLOT_NAME_DEFAULT, SLOT_NAME_HEADER } from '../../constants/slots'
5+
import { isTag } from '../../utils/dom'
56
import { identity } from '../../utils/identity'
67
import { hasNormalizedSlot, normalizeSlot } from '../../utils/normalize-slot'
78
import { omit } from '../../utils/object'
@@ -29,24 +30,25 @@ export const BDropdownGroup = /*#__PURE__*/ Vue.extend({
2930
functional: true,
3031
props,
3132
render(h, { props, data, slots, scopedSlots }) {
33+
const { id, variant, header, headerTag } = props
3234
const $slots = slots()
3335
const $scopedSlots = scopedSlots || {}
3436
const slotScope = {}
35-
const headerId = props.id ? `_bv_${props.id}_group_dd_header` : null
37+
const headerId = id ? `_bv_${id}_group_dd_header` : null
3638

3739
let $header = h()
38-
if (hasNormalizedSlot(SLOT_NAME_HEADER, $scopedSlots, $slots) || props.header) {
40+
if (hasNormalizedSlot(SLOT_NAME_HEADER, $scopedSlots, $slots) || header) {
3941
$header = h(
40-
props.headerTag,
42+
headerTag,
4143
{
4244
staticClass: 'dropdown-header',
43-
class: [props.headerClasses, { [`text-${props.variant}`]: props.variant }],
45+
class: [props.headerClasses, { [`text-${variant}`]: variant }],
4446
attrs: {
4547
id: headerId,
46-
role: 'heading'
48+
role: isTag(headerTag, 'header') ? null : 'heading'
4749
}
4850
},
49-
normalizeSlot(SLOT_NAME_HEADER, slotScope, $scopedSlots, $slots) || props.header
51+
normalizeSlot(SLOT_NAME_HEADER, slotScope, $scopedSlots, $slots) || header
5052
)
5153
}
5254

@@ -58,7 +60,7 @@ export const BDropdownGroup = /*#__PURE__*/ Vue.extend({
5860
staticClass: 'list-unstyled',
5961
attrs: {
6062
...(data.attrs || {}),
61-
id: props.id || null,
63+
id,
6264
role: 'group',
6365
'aria-describedby':
6466
[headerId, props.ariaDescribedBy]

src/components/dropdown/dropdown-header.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Vue, mergeData } from '../../vue'
22
import { NAME_DROPDOWN_HEADER } from '../../constants/components'
33
import { PROP_TYPE_STRING } from '../../constants/props'
4+
import { isTag } from '../../utils/dom'
45
import { omit } from '../../utils/object'
56
import { makeProp, makePropsConfigurable } from '../../utils/props'
67

@@ -23,18 +24,18 @@ export const BDropdownHeader = /*#__PURE__*/ Vue.extend({
2324
functional: true,
2425
props,
2526
render(h, { props, data, children }) {
26-
const { variant } = props
27+
const { tag, variant } = props
2728

2829
return h('li', mergeData(omit(data, ['attrs']), { attrs: { role: 'presentation' } }), [
2930
h(
30-
props.tag,
31+
tag,
3132
{
3233
staticClass: 'dropdown-header',
3334
class: { [`text-${variant}`]: variant },
3435
attrs: {
3536
...(data.attrs || {}),
3637
id: props.id || null,
37-
role: 'heading'
38+
role: isTag(tag, 'header') ? null : 'heading'
3839
},
3940
ref: 'header'
4041
},

0 commit comments

Comments
 (0)