-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(Table): make OnAutoFitContentAsync work #6856
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
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnhances the table component’s auto-fit feature by making the OnAutoFitContentAsync callback optional and using its returned width as the initial measurement before falling back to DOM-based width calculations. Class diagram for updated Table component auto-fit logicclassDiagram
class Table {
+OnAutoFitContentAsync: Func<string, Task<int>>
+AutoFitContentCallback: string | null
}
Table --|> "uses" OnAutoFitContentAsync
class TableJs {
+autoFitColumnWidth(table, col)
}
TableJs ..> Table : uses Table.options.AutoFitContentCallback
TableJs ..> OnAutoFitContentAsync : invokes if not null
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.
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 OnAutoFitContentAsync functionality for the Table component by adding proper null checking and handling for the auto-fit content callback.
- Added null safety checks for the auto-fit content callback before invoking it
- Modified the width calculation logic to use callback results when available or fall back to automatic calculation
- Updated the callback registration to only set the callback name when
OnAutoFitContentAsyncis not null
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Table.razor.js | Added null checking for autoFitContentCallback and improved width calculation logic |
| Table.razor.cs | Modified callback registration to conditionally set AutoFitContentCallback based on OnAutoFitContentAsync availability |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/Table/Table.razor.js:731-732` </location>
<code_context>
- const cell = row.cells[index];
- maxWidth = Math.max(maxWidth, calcCellWidth(cell));
- });
+ let maxWidth = widthValue;
+ if (maxWidth === 0) {
+ [...rows].forEach(row => {
+ const cell = row.cells[index];
</code_context>
<issue_to_address>
**issue (bug_risk):** Initial maxWidth assignment may cause issues if widthValue is negative.
If widthValue is negative, maxWidth will remain invalid since the recalculation is skipped. Check for widthValue > 0 to ensure only valid widths are used.
</issue_to_address>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 #6856 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31755 31755
Branches 4466 4466
=========================================
Hits 31755 31755
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:
|
Link issues
fixes #6855
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enable and improve support for the OnAutoFitContentAsync callback in the Table component, using the callback's returned width when provided and falling back to automatic cell measurement otherwise.
Enhancements: