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

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
rizkyyy
2024-10-19 17:29:06 +07:00
committed by GitHub
parent 20fb46a3ba
commit b72d3434e9

View File

@@ -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