Skip to content

Fix #7585: use real scrollbar width to fix footer misalignment - #8582

Merged
wenzhixin merged 1 commit into
developfrom
bug/7585
Nov 13, 2026
Merged

wenzhixin merged 1 commit into
developfrom
bug/7585

Conversation

@wenzhixin

@wenzhixin wenzhixin commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

🤔Type of Request

  • Bug fix
  • New feature
  • Improvement
  • Documentation
  • Other

🔗Resolves an issue?
Fix #7585
Related to #6006, #7090, #7578

📝Changelog

  • Core
  • Extensions
  • Fixed: Fixed the footer misalignment when horizontally scrolling a fixed-height table to the end (the footer overlapped the vertical scrollbar area because its margin-right was incorrectly calculated as 0).

Root cause

fitHeader()/fitFooter() inferred the vertical scrollbar's existence with hasScrollBar && scrollHeight > clientHeight + headerHeight, which can diverge from the browser's actual scrollbar rendering (e.g. Firefox on Windows), and used the globally measured Utils.getScrollBarWidth() instead of the scrollbar's real occupied width. When the inference produced 0, the footer's margin-right was set to 0 while the body still reserved a scrollbar, so scrolling horizontally to the end misaligned the footer against the header/body columns (a phantom vertical scrollbar could also appear).

Fix

  • fitHeader()/fitFooter() now use the real occupied width: fixedBody.offsetWidth - fixedBody.clientWidth.
  • resetView() re-fits the footer asynchronously after the container height is applied (the scrollbar only exists once the layout settles; the synchronous call ran too early).

Verified locally (A/B against CDN 1.23.5, same issue reproduction):

  • Before (1.23.5): footer margin-right: 0px, footer right edge 15px past the body when scrolled to the end.
  • After (this branch): footer/header margin-right: 15px, both aligned with the body.
  • Regression combos on one page (height + few rows / height + 30 rows real vertical overflow / no height with inline footer / height + pagination): all aligned, no regressions.
  • All 552 unit tests pass; eslint clean.

Compared to the draft #8419 (branch for #6006) which only dropped the hasScrollBar condition but kept the global getScrollBarWidth(), this uses the actual measured width and also fixes the footer fitting timing.

💡Example(s)?

Both examples force classic (space-taking) scrollbars via CSS so the behavior is visible on overlay-scrollbar platforms (e.g. macOS) too.

☑️Self Check before Merge

⚠️ Please check all items below before reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

@wenzhixin wenzhixin left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the footer misalignment when horizontally scrolling a fixed-height table to the end (#7585): instead of inferring the vertical scrollbar via hasScrollBar && scrollHeight > clientHeight + headerHeight and using the globally measured Utils.getScrollBarWidth(), fitHeader()/fitFooter() now use the real occupied width fixedBody.offsetWidth - fixedBody.clientWidth, and resetView() re-fits the footer asynchronously once the container height has settled.

Changes:

  • src/modules/header.js: both fitHeader() and fitFooter() compute scrollWidth from the element's actual offsetWidth - clientWidth, dropping the fragile hasScrollBar/scrollHeight inference and the global scrollbar-width measurement.
  • src/modules/body.js: resetView() schedules a delayed fitFooter() (delay 0, via the existing _setDelayTimeout('footer', ...)) after applying the container height, because the vertical scrollbar is only rendered after the layout settles.

Reviewed changes

Reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/modules/header.js fitHeader()/fitFooter() use the real scrollbar width (offsetWidth - clientWidth)
src/modules/body.js resetView() re-fits the footer asynchronously after the height is applied

Verification

  • fitFooter() computes scrollWidth identically to fitHeader(), so header/footer/body stay consistent (src/modules/header.js:449-450 vs :258-259).
  • offsetWidth - clientWidth is 0 when no vertical scrollbar is rendered, which preserves the no-scrollbar case without needing hasScrollBar (note: .fixed-table-body has overflow: auto, no border on the scroll container itself, so the subtraction isolates the scrollbar).
  • The delayed re-fit goes through _setDelayTimeout('footer', ...) (src/bootstrap-table.js:76-79), which clears any pending footer timeout, and destroy() clears all _timeoutId entries, so no leak or stale callback after destroy. fitFooter() itself re-schedules at 100ms while hidden, same as fitHeader().
  • The same !cardView && showFooter guard is used as the synchronous fitFooter() call earlier in resetView().
  • hasScrollBar is still computed and consumed in resetView() for $tableBorder (src/modules/body.js:464, :504) — pre-existing, unrelated to this fix.
  • CI Test/changes + Test/test green (552 unit tests). Static review only, no CI run locally.

Remaining notes (non-blocking)

  • tableBorderHeight still subtracts the global Utils.getScrollBarWidth() while the header/footer now use the measured width; on browsers where the two diverge (the exact case this PR fixes), the table border height may be off by the same difference. Worth a follow-up if misalignment of the bottom border is ever reported.

Recommendation: good to merge.

@wenzhixin
wenzhixin merged commit fe7fcea into develop Nov 13, 2026
2 checks passed
@wenzhixin
wenzhixin deleted the bug/7585 branch November 13, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Footer misalignment when scrolling table

1 participant