From b72d3434e9ab024e8622611d32b5a4467c8364b9 Mon Sep 17 00:00:00 2001 From: rizkyyy <60952577+rdjanuar@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:29:06 +0700 Subject: [PATCH] fix(Table): handle dot nation with `by` prop (#2413) Co-authored-by: Benjamin Canac --- src/runtime/components/data/Table.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/runtime/components/data/Table.vue b/src/runtime/components/data/Table.vue index 8a55b6cddc..473cc5ac43 100644 --- a/src/runtime/components/data/Table.vue +++ b/src/runtime/components/data/Table.vue @@ -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 > (key: string) { + return (obj: T) => get(obj, key) + } + function isSelected (row: TableRow) { if (!props.modelValue) { return false