fix(Table): calc table height incorrect when invisible at first render (#3980)

* fix: 修复不可见表格高度计算不正确问题

* refactor: 使用动画帧 api

* chore: bump version 8.8.2-beta02
This commit is contained in:
Argo Zhang 2024-08-05 16:56:45 +08:00 committed by GitHub
parent 3468812560
commit e2c60b7a9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>8.8.2-beta01</Version>
<Version>8.8.2-beta02</Version>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

View File

@ -190,6 +190,9 @@ export function dispose(id) {
Data.remove(id)
if (table) {
if (table.loopCheckHeightHandler) {
cancelAnimationFrame(table.loopCheckHeightHandler);
}
if (table.thead) {
EventHandler.off(table.body, 'scroll')
}
@ -243,6 +246,17 @@ const setColumnToolboxListener = table => {
}
}
const check = table => {
const el = table.el;
if (isVisible(el) === false) {
table.loopCheckHeightHandler = requestAnimationFrame(() => check(table));
}
else {
delete table.loopCheckHeightHandler;
setBodyHeight(table);
}
};
const setBodyHeight = table => {
const el = table.el
const children = [...el.children]
@ -250,6 +264,7 @@ const setBodyHeight = table => {
table.search = search;
if (isVisible(el) === false) {
table.loopCheckHeightHandler = requestAnimationFrame(() => check(table));
return;
}