feat: ListView grouping across all view types (Grid, Kanban, Gallery)#779
feat: ListView grouping across all view types (Grid, Kanban, Gallery)#779
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…Config from ListView - ListView.tsx: pass groupingConfig to kanban and gallery view schemas - ObjectGallery.tsx: add grouped sections with collapsible headers - ObjectKanban.tsx: map grouping.fields[0].field to swimlaneField fallback - KanbanSchema: add optional grouping field - Add GalleryGrouping.test.tsx (8 tests) and KanbanGrouping.test.tsx (6 tests) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估,需要完成所有开发需求 |
There was a problem hiding this comment.
Pull request overview
This PR extends ListView’s existing grouping state so it affects all supported view types (Grid, Kanban, Gallery), enabling consistent grouped rendering and behavior across views.
Changes:
- Pass
groupingConfigfromListViewinto the constructed Kanban and Gallery child schemas. - Add grouped rendering to
ObjectGallerywith collapsible group sections and group sorting. - Add Kanban schema support for
groupingand wiregrouping.fields[0].fieldas aswimlaneFieldfallback inObjectKanban.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-list/src/ListView.tsx | Forwards groupingConfig into kanban/gallery schema construction. |
| packages/plugin-list/src/ObjectGallery.tsx | Implements grouped + collapsible section rendering when schema.grouping is present. |
| packages/plugin-list/src/tests/GalleryGrouping.test.tsx | Adds unit tests for gallery grouping/collapse/sort/count behavior. |
| packages/plugin-kanban/src/ObjectKanban.tsx | Uses schema.grouping.fields[0].field as a swimlaneField fallback. |
| packages/plugin-kanban/src/types.ts | Adds grouping?: GroupingConfig to KanbanSchema. |
| packages/plugin-kanban/src/tests/KanbanGrouping.test.tsx | Adds tests around swimlane rendering and resolution logic. |
| groupField: schema.kanban?.groupField || schema.options?.kanban?.groupField || 'status', | ||
| titleField: schema.kanban?.titleField || schema.options?.kanban?.titleField || 'name', | ||
| cardFields: schema.kanban?.cardFields || effectiveFields || [], | ||
| ...(groupingConfig ? { grouping: groupingConfig } : {}), | ||
| ...(schema.options?.kanban || {}), | ||
| ...(schema.kanban || {}), |
There was a problem hiding this comment.
viewComponentSchema is memoized without groupingConfig in the dependency array, so changing grouping via the Group popover can leave the memoized schema stale and not propagate the new grouping prop to Kanban/Gallery (and Grid as well). Include groupingConfig (and any other referenced state like rowColorConfig / navigation.handleClick) in the useMemo dependencies, or remove the memoization if it’s not needed.
| <button | ||
| type="button" | ||
| className="flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors" | ||
| onClick={() => toggleGroup(group.key)} | ||
| > | ||
| {group.collapsed | ||
| ? <ChevronRight className="h-4 w-4 shrink-0" /> | ||
| : <ChevronDown className="h-4 w-4 shrink-0" />} | ||
| <span>{group.label}</span> | ||
| <span className="ml-auto text-xs text-muted-foreground">{group.items.length}</span> | ||
| </button> |
There was a problem hiding this comment.
The group toggle button controls visibility of the group content but doesn’t expose its expanded/collapsed state to assistive tech. Add aria-expanded (and ideally aria-controls pointing at the group panel) so screen readers can understand and announce the toggle state.
| // Clone schema to inject data and className | ||
| // Use grouping.fields[0].field as swimlaneField fallback when no explicit swimlaneField | ||
| const effectiveSwimlaneField = schema.swimlaneField | ||
| || (schema.grouping?.fields?.[0]?.field); | ||
|
|
||
| const effectiveSchema = { | ||
| ...schema, | ||
| data: effectiveData, | ||
| columns: effectiveColumns, | ||
| className: className || schema.className | ||
| className: className || schema.className, | ||
| ...(effectiveSwimlaneField ? { swimlaneField: effectiveSwimlaneField } : {}), | ||
| }; |
There was a problem hiding this comment.
The new grouping → swimlaneField fallback is not directly covered by a test that renders ObjectKanban with schema.grouping and asserts it actually produces a swimlane layout. Current tests exercise KanbanImpl and a copied resolver function, which won’t fail if ObjectKanban stops wiring schema.grouping into swimlaneField. Add an integration-level unit test for ObjectKanban covering explicit swimlaneField precedence and grouping fallback.
…ew propagation tests - Extract GroupRow component from inline ObjectGrid rendering - Add useGroupedData collapsed state tests (12 tests) - Add GroupRow component tests (11 tests) - Add ListView grouping config propagation tests (4 tests) - Export GroupRow and GroupRowProps from plugin-grid Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
All development requirements have been completed in commits Acceptance criteria fulfilled:
Full change list:
|
groupingConfigwas only wired to the Grid view. Kanban and Gallery views ignored it entirely, despite ListView already maintaining the state.Changes
aria-expandedaccessibility attributeGroupRowcomponent for grouped renderinggroupingConfigto kanban and gallery view schema construction (was only passed to grid)useGroupedDatapattern. Supportsfields[].collapsedinitial state and per-field sort ordergrouping.fields[0].field→swimlaneFieldfallback, reusing existing swimlane rendering. ExplicitswimlaneFieldtakes precedencegrouping?: GroupingConfigto the typeGroupRowcomponent andGroupRowPropstypeGallery grouping example
Tests (41 new tests)
useGroupedData.test.ts— 12 tests: collapsed state management, toggleGroup, multi-field grouping, sort order, empty labelsGroupRow.test.tsx— 11 tests: render, collapse/expand, aggregation summary, chevron icons, accessibility (aria-expanded)GalleryGrouping.test.tsx— 8 tests: grouped rendering, collapse/expand toggle, initial collapsed state, record counts, sort order, empty labelsKanbanGrouping.test.tsx— 6 tests: swimlane mapping, explicit swimlane priority, resolution logic edge casesListViewGroupingPropagation.test.tsx— 4 tests: verifies groupingConfig flows correctly to grid, kanban, and gallery view schemasOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.