Conversation
Contributor
Reviewer's GuideEnsures the Table column state cache is always kept in sync with the current columns (even when localStorage is unavailable) by rebuilding missing column entries from live columns and always updating cached column order on drag operations. Flow diagram for updated RebuildTableColumnFromCache behaviorflowchart TD
A[Start RebuildTableColumnFromCache] --> B[Loop Columns]
B --> C[GetFieldName]
C --> D[Find column in _tableColumnStateCache.Columns by Name]
D -->|column == null| E[Create new TableColumnState
Name, Width, Visible, DisplayName from col]
E --> F[Add TableColumnState to _tableColumnStateCache.Columns]
D -->|column != null| G[Set col.Width and col.Visible
from existing TableColumnState]
G --> H[Update TableColumnState.DisplayName
from col]
F --> I{More Columns?}
H --> I
I -->|Yes| B
I -->|No| J[End RebuildTableColumnFromCache]
Flow diagram for updated DragColumnCallback column order cachingflowchart TD
A[Start DragColumnCallback] --> B[Remove firstColumn from _tableColumnStates]
B --> C[Insert firstColumn at currentIndex in _tableColumnStates]
C --> D[Clear _tableColumnStateCache.Columns]
D --> E[AddRange _tableColumnStates to _tableColumnStateCache.Columns]
E --> F{OnDragColumnEndAsync != null?}
F -->|Yes| G[Invoke OnDragColumnEndAsync]
F -->|No| H[End DragColumnCallback]
G --> H
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
RebuildTableColumnFromCache, repeatedly callingList.Findinside theforeachleads to O(n^2) behavior for many columns; consider building aDictionary<string, TableColumnState>from_tableColumnStateCache.Columnsfirst to avoid repeated linear scans. - When creating a new
TableColumnStateinRebuildTableColumnFromCache, you’re usingcol.GetVisible()but later always writing back tocol.Visible; if there’s any difference between these, it might be clearer to standardize on one source of truth for visibility to avoid subtle inconsistencies.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `RebuildTableColumnFromCache`, repeatedly calling `List.Find` inside the `foreach` leads to O(n^2) behavior for many columns; consider building a `Dictionary<string, TableColumnState>` from `_tableColumnStateCache.Columns` first to avoid repeated linear scans.
- When creating a new `TableColumnState` in `RebuildTableColumnFromCache`, you’re using `col.GetVisible()` but later always writing back to `col.Visible`; if there’s any difference between these, it might be clearer to standardize on one source of truth for visibility to avoid subtle inconsistencies.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR targets the Table component’s column-state caching so that TableColumnStateCache is maintained even when ClientTableName (localStorage persistence) is not configured, addressing #7980.
Changes:
- Populate
_tableColumnStateCache.Columnsfrom currentColumnswhen no cached entry exists. - Update
_tableColumnStateCache.Columnsordering on drag regardless ofClientTableName.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1362
to
+1366
| // 设置列宽度与可见性 | ||
| var column = _tableColumnStateCache.Columns.Find(i => i.Name == fieldName); | ||
| if (column == null) | ||
| { | ||
| column = new TableColumnState() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link issues
fixes #7980
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Ensure table column state cache is kept in sync with table columns even when no persisted client-side storage is available.
New Features:
Enhancements: