Skip to content

fix(grid): fix scroll to bottom header not visible #3539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/vue/src/grid/src/table/src/utils/updateStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import GlobalConfig from '../../../config'

// 计算表格整体宽高
export function handleLayout(_vm) {
const { tableFullData, height, parentHeight, scrollXLoad, tableColumn } = _vm
const { tableFullData, height, parentHeight, scrollXLoad, scrollYLoad, tableColumn } = _vm
let { maxHeight, minHeight, totalWidth } = _vm
let customHeight, scaleToPx

Expand Down Expand Up @@ -67,6 +67,10 @@ export function handleLayout(_vm) {
_vm.bodyWrapperMinHeight = minHeight
}

if (scrollYLoad && !_vm.bodyWrapperHeight) {
_vm.bodyWrapperHeight = maxHeight
}
Comment on lines +70 to +72
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add null safety check for maxHeight assignment.

The conditional logic correctly addresses the scroll-to-bottom header visibility issue by ensuring bodyWrapperHeight is set when vertical scroll loading is enabled. However, there's a potential issue: maxHeight could be undefined if it wasn't initially set in _vm, which would result in assigning undefined to bodyWrapperHeight.

-  if (scrollYLoad && !_vm.bodyWrapperHeight) {
-    _vm.bodyWrapperHeight = maxHeight
-  }
+  if (scrollYLoad && !_vm.bodyWrapperHeight && maxHeight) {
+    _vm.bodyWrapperHeight = maxHeight
+  }

This ensures bodyWrapperHeight is only set when maxHeight has a valid value, preventing potential layout issues.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (scrollYLoad && !_vm.bodyWrapperHeight) {
_vm.bodyWrapperHeight = maxHeight
}
if (scrollYLoad && !_vm.bodyWrapperHeight && maxHeight) {
_vm.bodyWrapperHeight = maxHeight
}
🤖 Prompt for AI Agents
In packages/vue/src/grid/src/table/src/utils/updateStyle.ts around lines 70 to
72, add a null or undefined check for maxHeight before assigning it to
_vm.bodyWrapperHeight. Modify the condition to ensure _vm.bodyWrapperHeight is
only set if maxHeight has a valid (non-null and non-undefined) value to prevent
assigning undefined and causing layout issues.


_vm.bodyTableWidth = scrollXLoad
? tableColumn.reduce((previous, column) => previous + column.renderWidth, 0)
: totalWidth
Expand Down
Loading