From 1347fdf35a78d2e84ced95e723b52e25aef7dff9 Mon Sep 17 00:00:00 2001 From: LIUCHAO <50739490+Tsong-LC@users.noreply.github.com> Date: Thu, 25 Aug 2022 12:05:31 +0800 Subject: [PATCH] fix(components): [table] bodyWrapper resized calculate scrollbarStyle (#9149) * fix(components): [table] tableWrapper resized update scrollbar * fix(components): [table] Listen to the bodyWrapper * fix(components): [table] fix max-height * fix(components): [table] modify scrollbar height error --- packages/components/table/src/table/style-helper.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/components/table/src/table/style-helper.ts b/packages/components/table/src/table/style-helper.ts index ccdd92903b..13af1b939e 100644 --- a/packages/components/table/src/table/style-helper.ts +++ b/packages/components/table/src/table/style-helper.ts @@ -200,6 +200,11 @@ function useStyle( } else { useEventListener(window, 'resize', resizeListener) } + + useResizeObserver(table.refs.bodyWrapper, () => { + resizeListener() + table.refs?.scrollBarRef?.update() + }) } const resizeListener = () => { const el = table.vnode.el @@ -299,14 +304,14 @@ function useStyle( } if (props.maxHeight) { if (!Number.isNaN(Number(props.maxHeight))) { - const headerHeight = table.refs.headerWrapper?.scrollHeight || 0 - const footerHeight = table.refs.footerWrapper?.scrollHeight || 0 const maxHeight = props.maxHeight const reachMaxHeight = tableScrollHeight.value >= Number(maxHeight) if (reachMaxHeight) { return { maxHeight: `${ - tableScrollHeight.value - headerHeight - footerHeight + tableScrollHeight.value - + headerScrollHeight.value - + footerScrollHeight.value }px`, } }