Skip to content

fix(table):修复调整列宽时偶尔页面元素上列宽无值的问题 - #8326

Open
Tony-ST0754 wants to merge 2 commits into
mainfrom
fix-table-drag-column-width
Open

fix(table):修复调整列宽时偶尔页面元素上列宽无值的问题#8326
Tony-ST0754 wants to merge 2 commits into
mainfrom
fix-table-drag-column-width

Conversation

@Tony-ST0754

@Tony-ST0754 Tony-ST0754 commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

fix:修复调整列宽时偶尔页面元素上列宽无值的问题

Link issues

fixes #8323

根本原因 / Root Cause

由于组件内部有使用Responsive组件,感觉应该注释掉比较合适

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

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

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Bug Fixes:

  • Prevent column width recalculation during window resize that could leave colgroup column widths unset while adjusting column widths.

fix:修复调整列宽时偶尔页面元素上列宽无值的问题
@sourcery-ai

sourcery-ai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Stops recalculating/applying column minimum widths on window resize to avoid race conditions when user-adjusted widths are being dragged, and performs a minor formatting cleanup in autoFitColumnWidth.

Sequence diagram for window resize and table column width handling

sequenceDiagram
    participant Window
    participant ResizeObserver
    participant TableElement as Table

    Window->>ResizeObserver: resize event on body
    ResizeObserver->>TableElement: set table.minWidthRaf = requestAnimationFrame
    Note over TableElement: Previously: applyColumnMinWidth(table) called here
    TableElement-->>TableElement: table.minWidthRaf = null
    Note over TableElement: Now: applyColumnMinWidth(table) is skipped
    TableElement-->>Window: User drag column widths handled independently
Loading

File-Level Changes

Change Details Files
Disable applyColumnMinWidth execution inside the resize observer RAF callback to avoid clearing column widths during user drag operations.
  • Comment out applyColumnMinWidth(table) within the requestAnimationFrame callback used by the resize observer on table.body.
  • Add detailed comments (in Chinese) explaining that running column width recalculation on window resize conflicts with user drag operations and can result in colgroup col widths becoming empty due to subsequent setAutoColWidths calls.
src/BootstrapBlazor/Components/Table/Table.razor.js
Minor whitespace/formatting cleanup in autoFitColumnWidth implementation.
  • Remove trailing whitespace and normalize blank line between maxWidth calculation and header-included width logic.
src/BootstrapBlazor/Components/Table/Table.razor.js

Assessment against linked issues

Issue Objective Addressed Explanation
#8323 Prevent fast column width adjustments from being recalculated back to their original values after mouse release, so that column widths and table width remain correct and the width calculation is only performed once per resize operation.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto

bb-auto Bot commented Aug 14, 2026

Copy link
Copy Markdown

Thanks for your PR, @Tony-ST0754. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@bb-auto
bb-auto Bot requested a review from ArgoZhang August 14, 2026 04:50
@bb-auto bb-auto Bot added the bug Something isn't working label Aug 14, 2026
@bb-auto bb-auto Bot added this to the v10.9.0 milestone Aug 14, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Instead of fully commenting out applyColumnMinWidth(table) in the resize observer, consider guarding it with a condition (e.g., a flag indicating an active drag) so that normal resize behavior is preserved while still avoiding the drag-related race condition.
  • The long in-line comment explaining the root cause around applyColumnMinWidth is quite verbose; consider shortening it to the essential behavioral contract and moving deeper analysis to a separate design note or issue reference to keep the JS file easier to scan.
  • There appears to be a purely whitespace-only change around autoFitColumnWidth (line near maxWidth); consider dropping this to avoid noisy diffs if it’s not intentional.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of fully commenting out `applyColumnMinWidth(table)` in the resize observer, consider guarding it with a condition (e.g., a flag indicating an active drag) so that normal resize behavior is preserved while still avoiding the drag-related race condition.
- The long in-line comment explaining the root cause around `applyColumnMinWidth` is quite verbose; consider shortening it to the essential behavioral contract and moving deeper analysis to a separate design note or issue reference to keep the JS file easier to scan.
- There appears to be a purely whitespace-only change around `autoFitColumnWidth` (line near `maxWidth`); consider dropping this to avoid noisy diffs if it’s not intentional.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (88c0428) to head (d3d6762).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #8326   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          771       771           
  Lines        34535     34535           
=========================================
  Hits         34535     34535           
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

fix:更改浏览器窗口大小时,不应该将已由用户设置过的列宽重置为自动计算的列宽,应保存用户设置过的列宽
@Tony-ST0754

Copy link
Copy Markdown
Collaborator Author

这里还有一种情况,暂时也没想到很好的办法,现象如下:
1、页面刚打开时,各列都没有值,且浏览器窗口为最大化,如下图1所示,表格宽度值无
2、将浏览器取消最大化,浏览器窗口变小后,各列的值重新计算,并给各列元素的宽度赋值,表格宽度值无
3、再将浏览器窗口最大化,此时,问题来了,各列上的列宽度值,还是保存为非浏览器窗口最大化的值,固定表头时,表格线稍微有点错位,表格宽度值无
4、只有当用户调整任意列宽后,各列的值才会重算为正确的值
目前没想到什么好办法处理
QQ20260814-175350
QQ20260814-175416
QQ20260814-175440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(table): 快速调整列宽时,在松开鼠标后计算各列恢复原始值,但表格(两次)宽度重新计算后不正确

2 participants