Skip to content

Commit

Permalink
fix(b-table): only set aria-describedby when caption really exists (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmllr95 authored Dec 23, 2020
1 parent f2ffbeb commit b980017
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/components/table/helpers/mixin-caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export const captionMixin = Vue.extend({
props,
computed: {
captionId() {
// Even though `this.safeId` looks like a method, it is a computed prop
// that returns a new function if the underlying ID changes
return this.isStacked ? this.safeId('_caption_') : null
}
},
Expand All @@ -38,7 +36,8 @@ export const captionMixin = Vue.extend({
{
attrs: { id: this.captionId },
domProps: hasCaptionSlot ? {} : htmlOrText(captionHtml, caption),
key: 'caption'
key: 'caption',
ref: 'caption'
},
this.normalizeSlot(SLOT_NAME_TABLE_CAPTION)
)
Expand Down
9 changes: 3 additions & 6 deletions src/components/table/helpers/mixin-table-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,14 @@ export const tableRendererMixin = Vue.extend({
selectableTableAttrs
} = this

// Preserve user supplied aria-describedby, if provided in `$attrs`
const adb =
[(this.bvAttrs || {})['aria-describedby'], this.captionId].filter(identity).join(' ') ||
null

const ariaAttrs = this.isTableSimple
? {}
: {
'aria-busy': this.computedBusy ? 'true' : 'false',
'aria-colcount': toString(fields.length),
'aria-describedby': adb
// Preserve user supplied `aria-describedby`, if provided
'aria-describedby':
this.bvAttrs['aria-describedby'] || this.$refs.caption ? this.captionId : null
}

const rowCount =
Expand Down

0 comments on commit b980017

Please sign in to comment.