Skip to content

Commit 58e60be

Browse files
authored
Merge branch 'dev' into fix-sidebar-tab-trap-layout-change
2 parents 5c7f0be + 3f5a309 commit 58e60be

File tree

3 files changed

+59
-11
lines changed

3 files changed

+59
-11
lines changed

src/components/table/helpers/mixin-selectable.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ import { isArray, isNumber } from '../../../utils/inspect'
1212
import { looseEqual } from '../../../utils/loose-equal'
1313
import { mathMax, mathMin } from '../../../utils/math'
1414
import { makeProp } from '../../../utils/props'
15+
import { toString } from '../../../utils/string'
1516
import { sanitizeRow } from './sanitize-row'
1617

1718
// --- Constants ---
1819

1920
const SELECT_MODES = ['range', 'multi', 'single']
2021

22+
const ROLE_GRID = 'grid'
23+
2124
// --- Props ---
2225

2326
export const props = {
@@ -70,15 +73,19 @@ export const selectableMixin = Vue.extend({
7073
}
7174
},
7275
selectableTableAttrs() {
73-
return this.isSelectable
74-
? {
75-
role: 'grid',
76-
// TODO:
77-
// Should this attribute not be included when `no-select-on-click` is set
78-
// since this attribute implies keyboard navigation?
79-
'aria-multiselectable': String(this.selectableIsMultiSelect)
80-
}
81-
: {}
76+
if (!this.isSelectable) {
77+
return {}
78+
}
79+
80+
const role = this.bvAttrs.role || ROLE_GRID
81+
82+
return {
83+
role,
84+
// TODO:
85+
// Should this attribute not be included when `no-select-on-click` is set
86+
// since this attribute implies keyboard navigation?
87+
'aria-multiselectable': role === ROLE_GRID ? toString(this.selectableIsMultiSelect) : null
88+
}
8289
}
8390
},
8491
watch: {

src/components/table/helpers/mixin-table-renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const tableRendererMixin = Vue.extend({
115115
const ariaAttrs = this.isTableSimple
116116
? {}
117117
: {
118-
'aria-busy': this.computedBusy ? 'true' : 'false',
118+
'aria-busy': toString(this.computedBusy),
119119
'aria-colcount': toString(fields.length),
120120
// Preserve user supplied `aria-describedby`, if provided
121121
'aria-describedby':
@@ -135,7 +135,7 @@ export const tableRendererMixin = Vue.extend({
135135
...this.bvAttrs,
136136
// Now we can override any `$attrs` here
137137
id: this.safeId(),
138-
role: 'table',
138+
role: this.bvAttrs.role || 'table',
139139
...ariaAttrs,
140140
...selectableTableAttrs
141141
}

src/components/table/table-selectable.spec.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,47 @@ describe('table > row select', () => {
5252
wrapper.destroy()
5353
})
5454

55+
it('should apply user role if provided, grid role if multiselectable or table role otherwise', async () => {
56+
let wrapper = mount(BTable, {
57+
propsData: {
58+
fields: testFields,
59+
items: testItems
60+
}
61+
})
62+
63+
expect(wrapper).toBeDefined()
64+
await waitNT(wrapper.vm)
65+
66+
expect(wrapper.attributes('role')).toBe('table')
67+
wrapper.destroy()
68+
69+
wrapper = mount(BTable, {
70+
propsData: {
71+
fields: testFields,
72+
items: testItems,
73+
role: 'foobar'
74+
}
75+
})
76+
77+
await waitNT(wrapper.vm)
78+
79+
expect(wrapper.attributes('role')).toBe('foobar')
80+
wrapper.destroy()
81+
82+
wrapper = mount(BTable, {
83+
propsData: {
84+
fields: testFields,
85+
items: testItems,
86+
selectable: true
87+
}
88+
})
89+
90+
await waitNT(wrapper.vm)
91+
92+
expect(wrapper.attributes('role')).toBe('grid')
93+
wrapper.destroy()
94+
})
95+
5596
it('should have tabindex but not aria-selected when not selectable and has row-clicked listener', async () => {
5697
const wrapper = mount(BTable, {
5798
propsData: {

0 commit comments

Comments
 (0)