-
-
Notifications
You must be signed in to change notification settings - Fork 364
fix(Table): double click col trigger ResizeColumnCallback #6809
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 GuideThis PR refactors column width tooltip handling by extracting shared logic into a helper, adjusts the tooltip title generator to use the header element’s width, and triggers the user-provided resizeColumnCallback when a column is autofitted via double click. Sequence diagram for double-click column autofit triggering resizeColumnCallbacksequenceDiagram
participant User as actor User
participant Table as Table Component
participant JS as Table.razor.js
participant Callback as resizeColumnCallback
User->>Table: Double-click column header
Table->>JS: autoFitColumnWidth(table, col)
JS->>JS: Calculate maxWidth
JS->>Callback: invokeMethodAsync(resizeColumnCallback, index, maxWidth)
JS->>JS: resetColumnWidthTips(table, col)
Class diagram for refactored tooltip logic and callback integrationclassDiagram
class Table {
options
columns
invoke
}
class Tooltip {
tip
_config
update()
_isShown()
}
class EventHandler {
on()
}
class JS {
setResizeListener(table)
setColumnResizingListen(table, col)
autoFitColumnWidth(table, col)
resetColumnWidthTips(table, col)
getColumnTooltipTitle(options, th)
}
Table --> JS : uses
JS --> Tooltip : uses
JS --> EventHandler : uses
JS --> Table : calls invokeMethodAsync
JS --> "resizeColumnCallback" : invokes
JS --> Tooltip : calls getInstance/getOrCreateInstance
JS --> Tooltip : calls update
JS --> Tooltip : calls _isShown
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 an issue where double-clicking a table column should trigger the ResizeColumnCallback, ensuring proper callback invocation and tooltip updates during column auto-fit operations.
- Refactored tooltip handling logic into a reusable
resetColumnWidthTips
function - Added missing ResizeColumnCallback invocation in the
autoFitColumnWidth
function - Updated tooltip title generation to accept table header element instead of width value
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/BootstrapBlazor/Components/Table/Table.razor.js | Added callback invocation for double-click column resize and refactored tooltip handling |
src/BootstrapBlazor/BootstrapBlazor.csproj | Version bump to 9.11.1-beta01 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
setTableDefaultWidth(table); | ||
|
||
if (table.options.resizeColumnCallback) { | ||
await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth) |
Copilot
AI
Sep 30, 2025
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.
Missing semicolon at the end of the statement. JavaScript statements should end with semicolons for consistency and to avoid potential issues with automatic semicolon insertion.
await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth) | |
await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth); |
Copilot uses AI. Check for mistakes.
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 - here's some feedback:
- Consider also invoking
resizeColumnCallback
after manual drag-resize completes (in addition to double‐click auto‐fit) to keep the API consistent for consumers. - The
resetColumnWidthTips
helper sometimes takes a<th>
element and sometimes the resize handle; renaming its parameter or normalizing the input would improve clarity. - Previously the tooltip title calculation included
marginX
in the width—verify that the refactoredgetColumnTooltipTitle
still reflects any needed margin adjustments.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider also invoking `resizeColumnCallback` after manual drag-resize completes (in addition to double‐click auto‐fit) to keep the API consistent for consumers.
- The `resetColumnWidthTips` helper sometimes takes a `<th>` element and sometimes the resize handle; renaming its parameter or normalizing the input would improve clarity.
- Previously the tooltip title calculation included `marginX` in the width—verify that the refactored `getColumnTooltipTitle` still reflects any needed margin adjustments.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/Table/Table.razor.js:748-752` </location>
<code_context>
setTableDefaultWidth(table);
+
+ if (table.options.resizeColumnCallback) {
+ await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth)
+ }
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider error handling for async callback invocation.
Wrapping the async call in a try/catch block will help prevent unhandled promise rejections, particularly if the callback is user-defined.
```suggestion
setTableDefaultWidth(table);
if (table.options.resizeColumnCallback) {
try {
await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth);
} catch (error) {
console.error("Error invoking resizeColumnCallback:", error);
}
}
```
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
setTableDefaultWidth(table); | ||
|
||
if (table.options.resizeColumnCallback) { | ||
await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth) | ||
} |
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.
suggestion (bug_risk): Consider error handling for async callback invocation.
Wrapping the async call in a try/catch block will help prevent unhandled promise rejections, particularly if the callback is user-defined.
setTableDefaultWidth(table); | |
if (table.options.resizeColumnCallback) { | |
await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth) | |
} | |
setTableDefaultWidth(table); | |
if (table.options.resizeColumnCallback) { | |
try { | |
await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth); | |
} catch (error) { | |
console.error("Error invoking resizeColumnCallback:", error); | |
} | |
} |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6809 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31751 31751
Branches 4465 4465
=========================================
Hits 31751 31751
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 #6808
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Ensure auto-fit column width on double-click triggers the resizeColumnCallback and centralize tooltip update logic for column width tooltips
Bug Fixes:
Enhancements: