fix(virtualization): measure natural rows and align viewport geometry
This commit is contained in:
@@ -118,7 +118,10 @@ function focusRow(_key: string | number, index: number) {
|
||||
let detach: (() => void) | undefined;
|
||||
onMounted(() => {
|
||||
const element = scrollElement();
|
||||
if (element) detach = bindVirtualRows(rows, element);
|
||||
if (element)
|
||||
detach = bindVirtualRows(rows, element, {
|
||||
content: element.querySelector("tbody") ?? undefined,
|
||||
});
|
||||
});
|
||||
onUnmounted(() => detach?.());
|
||||
</script>
|
||||
@@ -133,12 +136,12 @@ onUnmounted(() => detach?.());
|
||||
>
|
||||
<TableContent
|
||||
aria-label="1000 行虚拟化表格"
|
||||
class="min-w-[700px] table-fixed"
|
||||
class="min-w-[700px]"
|
||||
:row-keys="rowKeys"
|
||||
:aria-rowcount="users.length + 1"
|
||||
@focus-row="focusRow"
|
||||
>
|
||||
<TableHeader aria-rowindex="1" class="h-full w-full">
|
||||
<TableHeader aria-rowindex="1" style="height: 42px" class="w-full">
|
||||
<TableColumn id="name" is-row-header :min-width="160">
|
||||
姓名
|
||||
</TableColumn>
|
||||
@@ -155,24 +158,15 @@ onUnmounted(() => detach?.());
|
||||
:key="user.id"
|
||||
:row-key="user.id"
|
||||
:aria-rowindex="user.id + 1"
|
||||
:style="{ height: ITEM_HEIGHT + 'px' }"
|
||||
:height="ITEM_HEIGHT"
|
||||
>
|
||||
<TableCell
|
||||
class="whitespace-nowrap overflow-hidden text-ellipsis"
|
||||
:style="{ height: ITEM_HEIGHT + 'px' }"
|
||||
>
|
||||
<TableCell>
|
||||
{{ user.name }}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
class="whitespace-nowrap overflow-hidden text-ellipsis"
|
||||
:style="{ height: ITEM_HEIGHT + 'px' }"
|
||||
>
|
||||
<TableCell>
|
||||
{{ user.role }}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
class="whitespace-nowrap overflow-hidden text-ellipsis"
|
||||
:style="{ height: ITEM_HEIGHT + 'px' }"
|
||||
>
|
||||
<TableCell>
|
||||
{{ user.email }}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user