Skip to content

Commit

Permalink
fix(Table): handle dot nation with by prop (#2413)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Canac <[email protected]>
  • Loading branch information
rdjanuar and benjamincanac authored Oct 19, 2024
1 parent 20fb46a commit b72d343
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/runtime/components/data/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,16 @@ export default defineComponent({
function compare (a: any, z: any) {
if (typeof props.by === 'string') {
const property = props.by as unknown as any
return a?.[property] === z?.[property]
const accesorFn = accessor(props.by)
return accesorFn(a) === accesorFn(z)
}
return props.by(a, z)
}
function accessor <T extends Record<string, any>> (key: string) {
return (obj: T) => get(obj, key)
}
function isSelected (row: TableRow) {
if (!props.modelValue) {
return false
Expand Down

0 comments on commit b72d343

Please sign in to comment.