Repository navigation
fix(Table): add fitAllColumnWidth javascript export method - #8645
Hidden character warning
Conversation
auto-fit every .col-resizer in the table. It calls autoFitColumnWidth with notify=false for each column to avoid multiple callbacks, then persists the column state and invokes the resizeColumnCallback once using the first column name.
Reviewer's GuideImplements fitAllColumnWidth by sequentially auto-fitting all table columns without intermediate callbacks, then persisting the combined column state and issuing one resize notification; existing single-column auto-fit behavior remains the default. Sequence diagram for fitting all table columnssequenceDiagram
participant Caller
participant Table
participant Column as col-resizer
participant Storage
participant Callback
Caller->>Table: fitAllColumnWidth(id)
Table->>Table: querySelectorAll('.col-resizer')
loop each column
Table->>Column: autoFitColumnWidth(table, col, false)
Column-->>Table: updated width
end
Table->>Table: getColumnStateObject(table)
Table->>Storage: saveColumnStateToLocalstorage(table, state)
Table->>Callback: invokeMethodAsync(resizeColumnCallback, firstColumnName, state)
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8645 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 776 776
Lines 35234 35234
=========================================
Hits 35234 35234
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/BootstrapBlazor/Components/Table/Table.razor.js" line_range="133" />
<code_context>
+
+ if (columns.length > 0) {
+ for (const col of columns) {
+ await autoFitColumnWidth(table, col, false);
+ }
+
</code_context>
<issue_to_address>
**Fixed columns overlap after fitting**
When the table has resizable fixed columns whose fitted widths differ from their previous widths, `autoFitColumnWidth` changes each column’s width but does not recalculate the `left`/`right` offsets of neighboring fixed columns. Unlike the drag-resize path, which calls `resizeNextFixedColumnWidth`, this loop leaves those offsets stale, so fitting fixed columns causes them to overlap or leave gaps.
Recalculate fixed-column offsets after fitting the columns, using the resulting widths.
</issue_to_address>
### Comment 2
<location path="src/BootstrapBlazor/Components/Table/Table.razor.js" line_range="143" />
<code_context>
+ await table.invoke.invokeMethodAsync(
+ table.options.resizeColumnCallback,
+ getColumnName(columns[0]),
+ state
+ );
+ }
</code_context>
<issue_to_address>
**Bulk resize reports one column**
When a consumer uses the callback’s name argument to identify the changed column, `fitAllColumnWidth` passes only the first column name to `ResizeColumnCallback`, so `OnTableColumnClientStatusChanged` consumers that use the name to identify which field changed are told that only that column changed, despite the state containing widths for all columns.
Provide a batch callback contract that identifies all changed columns, or document that this operation reports the first column as a batch marker and ensure consumers persist the full state rather than updating only the named field.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and if the auto-fit calculation is wrong, incorrect column widths can be saved in local storage and reported through the resize callback. Reverting removes the new action but not saved client-side widths; they are bounded and can be cleared or recalculated.
Blocking findings: src/BootstrapBlazor/Components/Table/Table.razor.js:133, src/BootstrapBlazor/Components/Table/Table.razor.js:143
Change Table.fitAllColumnWidth to pass "*" to the resizeColumnCallback instead of the first column's name. This signals that all columns were adjusted (rather than a specific column) and avoids relying on the first column identifier in the notification.
Update comment in src/BootstrapBlazor/Components/Table/Table.razor.js to indicate the resize callback is invoked with a wildcard ('*') to notify that all columns have been resized, rather than using the first column name. This is a comment-only clarification; no functional code changes were made.
auto-fit every .col-resizer in the table. It calls autoFitColumnWidth with notify=false for each column to avoid multiple callbacks, then persists the column state and invokes the resizeColumnCallback once using the first column name.
Link issues
fixes #8644
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enable reliable batch auto-fitting for visible table columns with consolidated state updates and notifications.
New Features:
Bug Fixes:
Enhancements:
Tests: