Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Table): handle dot nation with by prop #2413

Merged
merged 11 commits into from
Oct 19, 2024
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