Skip to content

Commit 503c74f

Browse files
authored
fix(b-button): add aria-disabled attribute when explicitly set (bootstrap-vue#7190)
1 parent 3cb115b commit 503c74f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/components/button/button.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ const computeAttrs = (props, data) => {
8484
const nonStandardTag = isNonStandardTag(props)
8585
const hashLink = link && props.href === '#'
8686
const role = data.attrs && data.attrs.role ? data.attrs.role : null
87+
const ariaDisabled =
88+
data.attrs && data.attrs['aria-disabled'] ? data.attrs['aria-disabled'] : null
8789
let tabindex = data.attrs ? data.attrs.tabindex : null
8890
if (nonStandardTag || hashLink) {
8991
tabindex = '0'
@@ -98,7 +100,7 @@ const computeAttrs = (props, data) => {
98100
// Except when link has `href` of `#`
99101
role: nonStandardTag || hashLink ? 'button' : role,
100102
// We set the `aria-disabled` state for non-standard tags
101-
'aria-disabled': nonStandardTag ? String(props.disabled) : null,
103+
'aria-disabled': nonStandardTag ? String(props.disabled) : ariaDisabled,
102104
// For toggles, we need to set the pressed state for ARIA
103105
'aria-pressed': toggle ? String(props.pressed) : null,
104106
// `autocomplete="off"` is needed in toggle mode to prevent some browsers

src/components/button/button.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ describe('button', () => {
176176
wrapper.destroy()
177177
})
178178

179+
it('button has aria-disabled attribute when explicitly set', () => {
180+
const wrapper = mount(BButton, {
181+
attrs: {
182+
'aria-disabled': 'true'
183+
}
184+
})
185+
186+
expect(wrapper.attributes('aria-disabled')).toBe('true')
187+
188+
wrapper.destroy()
189+
})
190+
179191
it('link has attribute aria-disabled when disabled set', async () => {
180192
const wrapper = mount(BButton, {
181193
propsData: {

0 commit comments

Comments
 (0)