Skip to content

Commit 8efa7ee

Browse files
fix(dropdown): aria-labbeledby for dropdowns
1 parent 4bbb949 commit 8efa7ee

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/components/dropdown/dropdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default {
6262
class: this.menuClasses,
6363
attrs: {
6464
role: this.role,
65-
'aria-labelledby': this.safeId(this.split ? '_BV_toggle_' : '_BV_button_')
65+
'aria-labelledby': this.safeId(this.split ? '_BV_button_' : '_BV_toggle_')
6666
},
6767
on: {
6868
mouseover: this.onMouseOver,

src/components/dropdown/dropdown.spec.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,22 @@ describe('dropdown', async () => {
108108
expect(Array.from(dd_6.$refs.menu.children).filter(node => node.classList.contains('dropdown-divider')).length).toBe(1)
109109
})
110110

111-
it('.dropdown menu aria-labelledby should target `_BV_button_` when not in split mode', async () => {
111+
it('.dropdown menu aria-labelledby should target `_BV_toggle_` when not in split mode', async () => {
112112
const { app: { $refs } } = window
113113
const { dd_1 } = $refs // eslint-disable-line camelcase
114114

115115
const menu = Array.from(dd_1.$el.children)
116116
.find(node => node.attributes.role && node.attributes.role.value === 'menu')
117117

118+
expect(menu.attributes['aria-labelledby'].value).toMatch(/_BV_toggle_$/)
119+
})
120+
it('.dropdown menu aria-labelledby should target `_BV_button_` when in split mode', async () => {
121+
const { app: { $refs } } = window
122+
const { dd_2 } = $refs // eslint-disable-line camelcase
123+
124+
const menu = Array.from(dd_2.$el.children)
125+
.find(node => node.attributes.role && node.attributes.role.value === 'menu')
126+
118127
expect(menu.attributes['aria-labelledby'].value).toMatch(/_BV_button_$/)
119128
})
120129
})

0 commit comments

Comments
 (0)