Skip to content

Commit e6a72de

Browse files
committed
fix(BTable): fixes sorted event not being emitted with the correct values.
BREAKING CHANGES: updated BTable sorted event output from an object to standalone args
1 parent 86a27fc commit e6a72de

File tree

1 file changed

+4
-3
lines changed
  • packages/bootstrap-vue-3/src/components/BTable

1 file changed

+4
-3
lines changed

packages/bootstrap-vue-3/src/components/BTable/BTable.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ interface BTableEmits {
216216
(e: 'selection', value: TableItem[]): void
217217
(e: 'update:sortBy', value: string): void
218218
(e: 'update:sortDesc', value: boolean): void
219-
(e: 'sorted', ...value: Parameters<(sort?: {by?: string; desc?: boolean}) => any>): void
219+
(e: 'sorted', ...value: Parameters<(sortBy: string, isDesc: boolean) => any>): void
220220
}
221221
222222
const emits = defineEmits<BTableEmits>()
@@ -308,13 +308,14 @@ const handleFieldSorting = (field: TableField) => {
308308
const fieldKey = typeof field === 'string' ? field : field.key
309309
const fieldSortable = typeof field === 'string' ? false : field.sortable
310310
if (isSortable.value === true && fieldSortable === true) {
311+
const sortDesc = !sortDescBoolean.value
311312
if (fieldKey === props.sortBy) {
312-
emits('update:sortDesc', !sortDescBoolean.value)
313+
emits('update:sortDesc', sortDesc)
313314
} else {
314315
emits('update:sortBy', typeof field === 'string' ? field : field.key)
315316
emits('update:sortDesc', false)
316317
}
317-
emits('sorted', {by: props.sortBy, desc: sortDescBoolean.value})
318+
if (props.sortBy !== undefined) emits('sorted', props.sortBy, sortDesc)
318319
}
319320
}
320321

0 commit comments

Comments
 (0)