Skip to content

Fix #7830: fixed the unexpected horizontal scrollbar with table-bordered and height set - #8586

Open
wenzhixin wants to merge 1 commit into
developfrom
bug/7830
Open

wenzhixin wants to merge 1 commit into
developfrom
bug/7830

Conversation

@wenzhixin

Copy link
Copy Markdown
Owner

🤔Type of Request

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

🔗Resolves an issue?

Fix #7830

📝Changelog

  • Core
  • Extensions
  • Update: Fixed the unexpected horizontal scrollbar shown when height is set together with the table-bordered class on pages without a global box-sizing: border-box rule

💡Example(s)?

Both examples add * { box-sizing: content-box } to simulate a host page without a global border-box rule (the live editor loads Bootstrap 5, whose universal border-box rule hides the defect), and force a 15px scrollbar so the difference is visible on overlay-scrollbar platforms. The After link is pinned to commit 4682dde because jsDelivr caches the %2F branch variant separately.

Root cause

src/modules/body.js:507 writes the table outerWidth to the .fixed-table-border div created in src/modules/initialization.js:156. That div has border-left/right: 1px, and without an explicit box-sizing its own borders are added on top of the width in content-box pages, making it 2px wider than the scroll container. Bootstrap pages are unaffected because their global box-sizing: border-box rule covers it. Adding box-sizing: border-box plus max-width: 100% makes the component independent of the host CSS.

Verification

  • yarn lint:css passed
  • Local A/B (1.28.0 CDN vs built src): body scrollWidth 1176 -> 1174, horizontal overflow gone; no regression with a vertical scrollbar or the loading state
  • Live A/B DOM assertions above

☑️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 #7830: on host pages without a global box-sizing: border-box rule, combining height with the table-bordered class made .fixed-table-border render 2px wider than the scroll container, producing an unexpected horizontal scrollbar. resetView() writes the table outerWidth into the div (src/modules/body.js:507) while the div carries border-left/right: 1px (src/themes/_theme.scss:201-202), so content-box pages add those borders on top of the width. Adding box-sizing: border-box + max-width: 100% makes the component independent of host CSS.

Changes:

  • src/themes/_theme.scss: .fixed-table-border under .fixed-height gains box-sizing: border-box and max-width: 100%, with an explanatory comment.

Reviewed changes

Reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

File Description
src/themes/_theme.scss border-box + width clamp on .fixed-table-border

Verification

  • Static cross-checks (no CI run locally):
    • Root cause confirmed: the div is only created for height + table-bordered (src/modules/initialization.js:155-158) and receives width: $bodyTable.outerWidth() inline (src/modules/body.js:507), so content-box pages render it 2px wider than the table.
    • The rule compiles to .bootstrap-table .fixed-table-container.fixed-height .fixed-table-border, matching addClass('fixed-height') on the container (initialization.js:149); _theme.scss is shared by all 5 themes via @use "../theme" and no _custom.scss overrides these properties.
    • Bonus effect verified as positive: initialization.js:158 also adds fixed-table-border to $tableLoading, so the loading overlay picks up the same declarations. The overlay already declares width/max-width: 100% (theme.scss:238-239) and gets an inline table outerWidth (header.js:295), so border-box fixes the same 2px overflow for the loading overlay on content-box pages, with no conflict.
    • No regression for the usual frameworks: Bootstrap/Bulma/Foundation/Materialize/Semantic all ship a global border-box rule, so both declarations are no-ops there; the clamp is also direction-agnostic for RTL.
  • CI on the PR head is green (lint incl. stylelint, vitest, cypress).

Recommendation: good to merge — the inline comment below is a confirm-intent note about an edge case, not a blocker.

Comment thread src/themes/_theme.scss Resolved

@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

Follow-up review after the push to 96e9bbb7. This PR fixes #7830: on host pages without a global box-sizing: border-box rule, height combined with table-bordered makes .fixed-table-border 2px wider than the scroll container, showing an unexpected horizontal scrollbar.

This second pass covers only the incremental change from the previously reviewed head 4682dde8, which is a single commit touching one file.

Changes since 4682dde8:

  • src/themes/_theme.scss: the comment above box-sizing: border-box / max-width: 100% was expanded to state the role of each declaration and to record the wide-table trade-off explicitly - when the table is wider than the body and scrolls horizontally, the clamp stops the div at the visible body width, so its right border no longer tracks the table's right edge. No CSS declaration changed; only comment lines were added (+6/-2).

Reviewed changes

Reviewed 1 out of 1 incrementally changed files (the full PR spans 1 file) and generated no new comments.

File Description
src/themes/_theme.scss Comment-only update documenting the border-box / max-width responsibilities and the intentional clamp behavior for wide tables

Verification

  • git diff 4682dde8..96e9bbb7 shows only comment lines under the .fixed-table-border rule; box-sizing: border-box and max-width: 100% are byte-identical to the previously reviewed head.
  • The comment matches the code: src/modules/body.js:507 sets width to $bodyTable.outerWidth(), and max-width: 100% resolves against the .fixed-table-container containing block, which is what produces the documented clamp.
  • The added lines are Sass silent comments (//), so they are stripped at compile time and the generated CSS is unchanged.
  • No JS or src/constants/index.js change, so the type generation drift check is not applicable.
  • CI Test/changes and Test/test are green on 96e9bbb7.

Remaining notes (non-blocking)

None - the single informational finding from the first pass (documenting the wide-table clamp trade-off) is now addressed.

Recommendation: good to merge.

This branch has not been deployed

No deployments
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: unexpected occurrence of scrollbars with height more then 650

1 participant