mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
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
This commit is contained in:
@@ -200,6 +200,11 @@ function useStyle<T>(
|
||||
} 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<T>(
|
||||
}
|
||||
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`,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user