Skip to content
  • PHP-Proxy

    PHP-Proxy

    Error accessing resource: 429 - Too Many Requests

  • Notifications You must be signed in to change notification settings
  • Fork 150
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9a4b648

Browse files
authoredJun 9, 2025
fix(BTableLite): field attribute isRowHeader now being respected (#2713)
1 parent 9e16b6a commit 9a4b648

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed
 

‎packages/bootstrap-vue-next/src/components/BTable/BTableLite.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@
8888
@mouseleave="!filterEvent($event) && emit('row-unhovered', item, itemIndex, $event)"
8989
@mousedown="handleMiddleClick(item, itemIndex, $event)"
9090
>
91-
<BTd
91+
<component
92+
:is="getCellComponent(field)"
9293
v-for="field in computedFields"
9394
:key="field.key"
9495
:variant="
@@ -121,7 +122,7 @@
121122
{{ formatItem(item, String(field.key), field.formatter) }}
122123
</template>
123124
</slot>
124-
</BTd>
125+
</component>
125126
</BTr>
126127

127128
<template
@@ -518,6 +519,13 @@ const getRowClasses = (item: Items | null, type: TableRowType) =>
518519
const generateTableRowId = (primaryKeyValue: string) =>
519520
`${computedId.value}__row_${primaryKeyValue}`
520521
522+
const getCellComponent = (field: Readonly<TableField>) => {
523+
if (field?.isRowHeader) {
524+
return BTh
525+
}
526+
return BTd
527+
}
528+
521529
const computedSimpleProps = computed(() => ({
522530
...pick(props, btableSimpleProps),
523531
tableClass: computedTableClasses.value,

‎packages/bootstrap-vue-next/src/components/BTable/table-lite.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,4 +528,35 @@ describe('btablelite', () => {
528528
expect(wrapper.text()).not.toContain('foobar!')
529529
})
530530
})
531+
describe('isRowHeader field property', () => {
532+
it('sets td/th appropriately based on isRowHeader is true, false, or undefined', async () => {
533+
const items = [{isActive: true, age: 40, name: {first: 'Dickerson', last: 'Macdonald'}}]
534+
const fields = [
535+
{key: 'name.first', label: 'Actions', isRowHeader: true, class: 'first-name'},
536+
{key: 'age', label: 'Age', isRowHeader: false, class: 'age'},
537+
{key: 'isActive', label: 'Active', isRowHeader: false, class: 'active'},
538+
]
539+
const wrapper = mount(BTableLite, {
540+
props: {
541+
items,
542+
fields,
543+
},
544+
})
545+
const $tbody = wrapper.get('tbody')
546+
const $tr = $tbody.find('tr')
547+
expect($tr.find('th.first-name').exists()).toBe(true)
548+
expect($tr.find('td.age').exists()).toBe(true)
549+
expect($tr.find('td.active').exists()).toBe(true)
550+
await wrapper.setProps({
551+
fields: [
552+
{key: 'name.first', label: 'Actions', isRowHeader: false, class: 'first-name'},
553+
{key: 'age', label: 'Age', isRowHeader: false, class: 'age'},
554+
{key: 'isActive', label: 'Active', isRowHeader: false, class: 'active'},
555+
],
556+
})
557+
expect($tr.find('th.first-name').exists()).toBe(false)
558+
expect($tr.find('td.age').exists()).toBe(true)
559+
expect($tr.find('td.active').exists()).toBe(true)
560+
})
561+
})
531562
})

0 commit comments

Comments
 (0)
Failed to load comments.