mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-02-01 20:57:57 +01:00
fix(Table): handle dot nation with by prop (#2413)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user