fix: 修复CRUD nested 模式展示异常 (#9488)

This commit is contained in:
liaoxuezhi 2024-01-22 22:08:58 +08:00 committed by GitHub
parent 52b6bba766
commit 55c8243b73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View File

@ -70,7 +70,11 @@ export const Column = types
get isPrimary() {
const table = getParent(self, 2) as any;
return table.filteredColumns[0]?.id === self.id;
return (
table.filteredColumns.find(
(column: any) => !column.type.startsWith('__')
)?.id === self.id
);
}
}))
.actions(self => ({

View File

@ -170,7 +170,7 @@ export function Cell({
);
}
return [prefix, affix, addtionalClassName];
}, [item.expandable, item.expanded, column.isPrimary]);
}, [item.expandable, item.expanded, column.isPrimary, store.isNested]);
// 根据条件缓存 data避免孩子重复渲染
const hasCustomTrackExpression =

View File

@ -355,12 +355,15 @@ export default observer((props: TableRowProps) => {
id={item.id}
newIndex={item.newIndex}
isHover={item.isHover}
partial={item.partial}
checked={item.checked}
modified={item.modified}
moved={item.moved}
depth={item.depth}
expandable={item.expandable}
checkdisable={item.checkdisable}
loading={item.loading}
error={item.error}
// data 在 TableRow 里面没有使用,这里写上是为了当列数据变化的时候 TableRow 重新渲染,
// 不是 item.locals 的原因是 item.locals 会变化多次,比如父级上下文变化也会进来,但是 item.data 只会变化一次。
data={canAccessSuperData ? item.locals : item.data}