Skip to content

Commit 9526a1b

Browse files
committed
fix(Table)!: consistent args order in select event
1 parent 70aaf4a commit 9526a1b

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

docs/app/components/content/examples/table/TableRowSelectEventExample.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,9 @@ const table = useTemplateRef('table')
103103
104104
const rowSelection = ref<Record<string, boolean>>({ })
105105
106-
function onSelect(row: TableRow<Payment>, e?: Event) {
106+
function onSelect(e: Event, row: TableRow<Payment>) {
107107
/* If you decide to also select the column you can do this */
108108
row.toggleSelected(!row.getIsSelected())
109-
110-
console.log(e)
111109
}
112110
</script>
113111

docs/content/docs/2.components/table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ You can use the `row-selection` prop to control the selection state of the rows
328328
You can add a `@select` listener to make rows clickable with or without a checkbox column.
329329

330330
::note
331-
The handler function receives the `TableRow` instance as the first argument and an optional `Event` as the second argument.
331+
The handler function receives the `Event` and `TableRow` instance as the first and second arguments respectively.
332332
::
333333

334334
::component-example

playgrounds/nuxt/app/pages/components/table.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ function randomize() {
320320
321321
const rowSelection = ref<Record<string, boolean>>({})
322322
323-
function onSelect(row: TableRow<Payment>) {
323+
function onSelect(e: Event, row: TableRow<Payment>) {
324324
row.toggleSelected(!row.getIsSelected())
325325
}
326326

src/runtime/components/Table.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export interface TableProps<T extends TableData = TableData> extends TableOption
197197
* @see [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)
198198
*/
199199
facetedOptions?: FacetedOptions<T>
200-
onSelect?: (row: TableRow<T>, e?: Event) => void
200+
onSelect?: (e: Event, row: TableRow<T>) => void
201201
onHover?: (e: Event, row: TableRow<T> | null) => void
202202
onContextmenu?: ((e: Event, row: TableRow<T>) => void) | Array<((e: Event, row: TableRow<T>) => void)>
203203
class?: any
@@ -437,8 +437,7 @@ function onRowSelect(e: Event, row: TableRow<T>) {
437437
e.preventDefault()
438438
e.stopPropagation()
439439
440-
// FIXME: `e` should be the first argument for consistency
441-
props.onSelect(row, e)
440+
props.onSelect(e, row)
442441
}
443442
444443
function onRowHover(e: Event, row: TableRow<T> | null) {

0 commit comments

Comments
 (0)