From e332b1446f0c342bc7693b9214a5db28e9631ad0 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 18 Dec 2024 14:58:03 +0800 Subject: [PATCH] feat(SelectTable): support auto fill when collapse search panel (#4881) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 重构脚本 * chore: bump version 9.1.6-beta01 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- .../Components/Table/Table.razor.js | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index ab1fc6df3fa..1cc7f87b6bd 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.1.5 + 9.1.6-beta01 diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.js b/src/BootstrapBlazor/Components/Table/Table.razor.js index fba8039ed26..1aafd4dbea9 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.js +++ b/src/BootstrapBlazor/Components/Table/Table.razor.js @@ -51,6 +51,7 @@ export function reset(id) { const shim = [...table.el.children].find(i => i.classList.contains('table-shim')) if (shim !== void 0) { + table.shim = shim; table.thead = [...shim.children].find(i => i.classList.contains('table-fixed-header')) table.isResizeColumn = shim.classList.contains('table-resize') if (table.thead) { @@ -102,13 +103,23 @@ export function reset(id) { table.pages = [...table.el.children].find(i => i.classList.contains('nav-pages')); - setBodyHeight(table) setColumnToolboxListener(table); + if (isVisible(table.el) === false) { + table.loopCheckHeightHandler = requestAnimationFrame(() => check(table)); + return; + } + + observeHeight(table) +} + +const observeHeight = table => { + setBodyHeight(table); + const observer = new ResizeObserver(entries => { entries.forEach(entry => { - if (entry.target === shim) { + if (entry.target === table.shim) { setTableDefaultWidth(table); } else if (entry.target === table.search || entry.target === table.toolbar || entry.target === table.pages) { @@ -117,7 +128,7 @@ export function reset(id) { }); }); if (table.thead) { - observer.observe(shim); + observer.observe(table.shim); } if (table.search) { observer.observe(table.search); @@ -280,18 +291,16 @@ const check = table => { table.loopCheckHeightHandler = requestAnimationFrame(() => check(table)); } else { - delete table.loopCheckHeightHandler; - setBodyHeight(table); + if (table.loopCheckHeightHandler > 0) { + cancelAnimationFrame(table.loopCheckHeightHandler); + delete table.loopCheckHeightHandler; + } + observeHeight(table); } }; const setBodyHeight = table => { const el = table.el - if (isVisible(el) === false) { - table.loopCheckHeightHandler = requestAnimationFrame(() => check(table)); - return; - } - const children = [...el.children] const search = children.find(i => i.classList.contains('table-search')) table.search = search;