refactor(Table): update calc cell width logic#8013
Conversation
Reviewer's GuideRefactors the table cell width calculation to more accurately measure form controls inside cells by cloning them with adjusted widths, while also extracting reusable helpers for horizontal style widths and updating a version tag comment in the C# component. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
getFormControlTextWidth, repeatedly creating and appending a new span for every control can be expensive in large tables; consider reusing a single hidden measurement element or a small pool of them to reduce DOM churn. - The
resetFormControlWidthlogic assumes that the querySelectorAll order in the source and cloned cells will always match; if the clone's structure ever diverges (e.g., due to conditional content), this could misalign widths—consider a more robust mapping, such as matching by a data attribute or index checks with early return.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `getFormControlTextWidth`, repeatedly creating and appending a new span for every control can be expensive in large tables; consider reusing a single hidden measurement element or a small pool of them to reduce DOM churn.
- The `resetFormControlWidth` logic assumes that the querySelectorAll order in the source and cloned cells will always match; if the clone's structure ever diverges (e.g., due to conditional content), this could misalign widths—consider a more robust mapping, such as matching by a data attribute or index checks with early return.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8013 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 766 766
Lines 34123 34123
Branches 4692 4692
=========================================
Hits 34123 34123
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors Table column auto-fit width calculation, focusing on more accurate sizing for form controls inside table cells while updating package/API version metadata.
Changes:
- Adds helper logic to measure form-control text width during table cell width calculation.
- Removes the temporary cloned measurement element after use.
- Bumps the BootstrapBlazor package beta version and adjusts a Table API version tag.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/BootstrapBlazor/Components/Table/Table.razor.js |
Updates auto-fit cell width calculation for form controls and cleans up measurement DOM. |
src/BootstrapBlazor/Components/Table/Table.razor.cs |
Adjusts the documented version for ScrollIntoViewBehavior. |
src/BootstrapBlazor/BootstrapBlazor.csproj |
Bumps package version from 10.6.1-beta22 to 10.6.1-beta23. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const getFormControlTextWidth = control => { | ||
| const style = getComputedStyle(control); | ||
| const span = document.createElement('span'); | ||
| span.textContent = control.value || control.getAttribute('placeholder') || ' '; |
Link issues
fixes #8012
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Refine table cell width calculation to better account for form controls and horizontal padding/borders, improving column auto-fit behavior.
Bug Fixes:
Enhancements:
Documentation: