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) { function compare (a: any, z: any) {
if (typeof props.by === 'string') { if (typeof props.by === 'string') {
const property = props.by as unknown as any const accesorFn = accessor(props.by)
return a?.[property] === z?.[property] return accesorFn(a) === accesorFn(z)
} }
return props.by(a, 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) { function isSelected (row: TableRow) {
if (!props.modelValue) { if (!props.modelValue) {
return false return false