Skip to content

Commit

Permalink
fix(b-table, b-table-lite, b-table-simple): handle header variant for…
Browse files Browse the repository at this point in the history
… sticky columns (fixes #5278) (#5279)

Co-authored-by: Jacob Müller
  • Loading branch information
tmorehouse committed Apr 30, 2020
1 parent bc199de commit 53e309e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/components/table/tbody.js
Expand Up @@ -12,6 +12,9 @@ export const props = {
}
}

// TODO:
// In Bootstrap v5, we won't need "sniffing" as table element variants properly inherit
// to the child elements, so this can be converted to a functional component
// @vue/component
export const BTbody = /*#__PURE__*/ Vue.extend({
name: 'BTbody',
Expand Down Expand Up @@ -60,7 +63,7 @@ export const BTbody = /*#__PURE__*/ Vue.extend({
// background color inheritance with Bootstrap v4 table CSS
return !this.isStacked && this.bvTable.stickyHeader
},
tableVariant() /* istanbul ignore next: Not currently sniffed in tests */ {
tableVariant() {
// Sniffed by <b-tr> / <b-td> / <b-th>
return this.bvTable.tableVariant
},
Expand Down
11 changes: 7 additions & 4 deletions src/components/table/td.js
Expand Up @@ -38,6 +38,9 @@ export const props = {
}
}

// TODO:
// In Bootstrap v5, we won't need "sniffing" as table element variants properly inherit
// to the child elements, so this can be converted to a functional component
// @vue/component
export const BTd = /*#__PURE__*/ Vue.extend({
name: 'BTableCell',
Expand Down Expand Up @@ -104,8 +107,7 @@ export const BTd = /*#__PURE__*/ Vue.extend({
headVariant() {
return this.bvTableTr.headVariant
},
/* istanbul ignore next: need to add in tests for footer variant */
footVariant() /* istanbul ignore next: need to add in tests for footer variant */ {
footVariant() {
return this.bvTableTr.footVariant
},
tableVariant() {
Expand All @@ -120,11 +122,12 @@ export const BTd = /*#__PURE__*/ Vue.extend({
cellClasses() {
// We use computed props here for improved performance by caching
// the results of the string interpolation
// TODO: need to add handling for footVariant
let variant = this.variant
if (
(!variant && this.isStickyHeader && !this.headVariant) ||
(!variant && this.isStickyColumn)
(!variant && this.isStickyColumn && this.inTfoot && !this.footVariant) ||
(!variant && this.isStickyColumn && this.inThead && !this.headVariant) ||
(!variant && this.isStickyColumn && this.inTbody)
) {
// Needed for sticky-header mode as Bootstrap v4 table cells do
// not inherit parent's background-color. Boo!
Expand Down
7 changes: 5 additions & 2 deletions src/components/table/tfoot.js
Expand Up @@ -8,6 +8,9 @@ export const props = {
}
}

// TODO:
// In Bootstrap v5, we won't need "sniffing" as table element variants properly inherit
// to the child elements, so this can be converted to a functional component
// @vue/component
export const BTfoot = /*#__PURE__*/ Vue.extend({
name: 'BTfoot',
Expand All @@ -33,7 +36,7 @@ export const BTfoot = /*#__PURE__*/ Vue.extend({
// Sniffed by <b-tr> / <b-td> / <b-th>
return true
},
isDark() /* istanbul ignore next: Not currently sniffed in tests */ {
isDark() {
// Sniffed by <b-tr> / <b-td> / <b-th>
return this.bvTable.dark
},
Expand All @@ -56,7 +59,7 @@ export const BTfoot = /*#__PURE__*/ Vue.extend({
// background color inheritance with Bootstrap v4 table CSS
return !this.isStacked && this.bvTable.stickyHeader
},
tableVariant() /* istanbul ignore next: Not currently sniffed in tests */ {
tableVariant() {
// Sniffed by <b-tr> / <b-td> / <b-th>
return this.bvTable.tableVariant
},
Expand Down
3 changes: 3 additions & 0 deletions src/components/table/th.js
@@ -1,6 +1,9 @@
import Vue from '../../utils/vue'
import { BTd } from './td'

// TODO:
// In Bootstrap v5, we won't need "sniffing" as table element variants properly inherit
// to the child elements, so this can be converted to a functional component
// @vue/component
export const BTh = /*#__PURE__*/ Vue.extend({
name: 'BTh',
Expand Down
3 changes: 3 additions & 0 deletions src/components/table/thead.js
Expand Up @@ -9,6 +9,9 @@ export const props = {
}
}

// TODO:
// In Bootstrap v5, we won't need "sniffing" as table element variants properly inherit
// to the child elements, so this can be converted to a functional component
// @vue/component
export const BThead = /*#__PURE__*/ Vue.extend({
name: 'BThead',
Expand Down
3 changes: 3 additions & 0 deletions src/components/table/tr.js
Expand Up @@ -11,6 +11,9 @@ export const props = {
const LIGHT = 'light'
const DARK = 'dark'

// TODO:
// In Bootstrap v5, we won't need "sniffing" as table element variants properly inherit
// to the child elements, so this can be converted to a functional component
// @vue/component
export const BTr = /*#__PURE__*/ Vue.extend({
name: 'BTr',
Expand Down

0 comments on commit 53e309e

Please sign in to comment.