Prevent tables grid from losing columns

This commit is contained in:
2026-03-21 16:24:58 +01:00
parent 7a0ce00429
commit 790eef5665
3 changed files with 37 additions and 4 deletions

View File

@@ -73,6 +73,7 @@ It is intentionally implementation-focused:
| 2026-03-21 | P3.10 | Completed | Softened the default `Reference` mode by replacing repeated curation wording in resting cells with subtle status indicators and by simplifying the top-level guidance copy. |
| 2026-03-21 | P3.11 | Completed | Moved the live editor and curation entry points into the shared inspector content and removed the last remaining grid-owned action buttons. |
| 2026-03-21 | P3.12 | Completed | Added keyboard-selectable cells, visible focus treatment, and selection normalization so changing filters or modes cannot leave the inspector pointing at hidden cells. |
| 2026-03-21 | Post-P3 fix 1 | Completed | Added a defensive visible-column fallback in the table canvas and tightened view-state normalization so a stale severity filter cannot collapse the grid to roll bands only. |
### Lessons Learned
@@ -114,6 +115,7 @@ It is intentionally implementation-focused:
- Help content should not stay embedded in the canvas component once the grid becomes the main task surface. Moving legend rendering back to the page host makes it easier to demote, reposition, or merge with future help surfaces.
- Hiding maintenance noise in default reference mode is mostly a copy and chrome problem, not a routing or data problem. Replacing repeated curation words with quieter indicators goes further than adding yet another toggle.
- Once the inspector owns the action entry points, the grid should stop carrying legacy button styles and callbacks. Removing dead grid-action code immediately keeps the browse-first model from drifting back toward edit-first behavior.
- Filtered table rendering needs a non-empty fallback set for structural axes such as columns. Even when the host page tries to normalize stale filter state, the canvas should never assume a filtered axis remains populated.
## Target Outcomes

View File

@@ -759,7 +759,12 @@
selectedGroupKey = string.Empty;
}
if (tableDetail.Columns.All(column => !string.Equals(column.Key, selectedColumnKey, StringComparison.OrdinalIgnoreCase)))
var matchingColumns = tableDetail.Columns
.Where(column => string.IsNullOrWhiteSpace(selectedColumnKey)
|| string.Equals(column.Key, selectedColumnKey, StringComparison.OrdinalIgnoreCase))
.ToList();
if (matchingColumns.Count == 0)
{
selectedColumnKey = string.Empty;
}

View File

@@ -129,9 +129,11 @@
cellIndex[(cell.RollBand, cell.GroupKey, cell.ColumnKey)] = cell;
}
var columnsToDisplay = ResolveVisibleColumns();
if (Detail.Groups.Count == 0)
{
foreach (var column in Detail.Columns.Where(MatchesColumnFilter))
foreach (var column in columnsToDisplay)
{
visibleColumns.Add(column);
displayColumns.Add((null, column.Key, column.Label));
@@ -139,12 +141,14 @@
}
else
{
foreach (var group in Detail.Groups.Where(MatchesGroupFilter))
var groupsToDisplay = ResolveVisibleGroups();
foreach (var group in groupsToDisplay)
{
visibleGroups.Add(group);
}
foreach (var column in Detail.Columns.Where(MatchesColumnFilter))
foreach (var column in columnsToDisplay)
{
visibleColumns.Add(column);
}
@@ -173,6 +177,28 @@
string.IsNullOrWhiteSpace(SelectedColumnKey)
|| string.Equals(column.Key, SelectedColumnKey, StringComparison.OrdinalIgnoreCase);
private IReadOnlyList<CriticalGroupReference> ResolveVisibleGroups()
{
var filteredGroups = Detail.Groups
.Where(MatchesGroupFilter)
.ToList();
return filteredGroups.Count > 0
? filteredGroups
: Detail.Groups;
}
private IReadOnlyList<CriticalColumnReference> ResolveVisibleColumns()
{
var filteredColumns = Detail.Columns
.Where(MatchesColumnFilter)
.ToList();
return filteredColumns.Count > 0
? filteredColumns
: Detail.Columns;
}
private bool MatchesModeFilter(CriticalTableCellDetail cell) =>
CurrentMode switch
{