Skip to content

Conversation

@kmelve
Copy link
Member

@kmelve kmelve commented Nov 7, 2025

Summary

This PR implements support for custom views and overview components in Structure Builder list panes, enabling developers to create more flexible and customizable list experiences in Sanity Studio.

Features

1. List Views

Add .views() method to ListBuilder enabling custom view components alongside the default list view:

S.list()
  .title('My List')
  .items([...])
  .views([
    S.view.component(CustomView).id('custom').title('Custom View')
  ])

Implementation:

  • Extended ListBuilder with views() method accepting array of ViewBuilder objects
  • Created ListPaneContext and useListPane hook for state management
  • Added ListHeaderTabs component for view tab navigation
  • Modified ListPaneContent to switch between default list and custom views
  • View state persists in URL via ?view=viewId parameter

2. List Overview

Add .overview() method to ListBuilder for displaying a default component in the center pane when no list item is selected:

S.list()
  .title('My List')
  .items([...])
  .overview(
    S.component(OverviewComponent).id('overview')
  )

Implementation:

  • Extended ListBuilder with overview() method accepting Component/ComponentBuilder/ComponentInput
  • Modified createResolvedPaneNodeStream.ts to create implicit child pane when list has overview
  • Created createOverviewChildResolver() for navigation between overview and list items
  • Overview appears in center pane by default when no item selected
  • Selecting a list item navigates to that item's child pane

Files Modified

  • packages/sanity/src/structure/structureBuilder/List.ts
  • packages/sanity/src/structure/types.ts
  • packages/sanity/src/structure/panes/list/ListPane.tsx
  • packages/sanity/src/structure/panes/list/ListPaneContent.tsx
  • packages/sanity/src/structure/panes/list/ListPaneHeader.tsx
  • packages/sanity/src/structure/structureResolvers/createResolvedPaneNodeStream.ts

Files Created

  • packages/sanity/src/structure/panes/list/ListPaneContext.ts
  • packages/sanity/src/structure/panes/list/useListPane.ts
  • packages/sanity/src/structure/panes/list/ListHeaderTabs.tsx
  • dev/test-studio/components/listViews/CustomListView.tsx
  • dev/test-studio/components/listViews/ListOverview.tsx

Testing

Test examples have been added to dev/test-studio/structure/resolveStructure.ts:

  1. List with Views - Demonstrates custom view components
  2. List with Overview - Demonstrates overview component that appears by default

Design Decisions

Following Established Patterns

  • Views implementation mirrors DocumentBuilder/DocumentPane patterns
  • Tab navigation follows existing DocumentHeaderTabs patterns
  • Component serialization uses existing ComponentBuilder patterns
  • Pane resolution follows existing implicit pane creation patterns (like __edit__)

Overview as Sibling Pane

The overview renders as a separate pane in the center (not inside the list pane), which:

  • Provides more space for overview content
  • Maintains consistency with how document editors work
  • Uses the same navigation patterns as list item children

🤖 Generated with Claude Code

Implements support for custom views and overview components in Structure Builder list panes:

1. **List Views** - Add `.views()` method to ListBuilder enabling custom view components:
   - Extended ListBuilder with views() method accepting array of ViewBuilder objects
   - Created ListPaneContext and useListPane hook for state management
   - Added ListHeaderTabs component for view tab navigation
   - Modified ListPaneContent to switch between default list and custom views
   - View state persists in URL via ?view=viewId parameter

2. **List Overview** - Add `.overview()` method to ListBuilder for default child pane:
   - Extended ListBuilder with overview() method accepting Component/ComponentBuilder/ComponentInput
   - Modified createResolvedPaneNodeStream.ts to create implicit child pane when list has overview
   - Created createOverviewChildResolver() for navigation between overview and list items
   - Overview appears in center pane by default when no item selected
   - Selecting a list item navigates to that item's child pane

Usage:
```typescript
S.list()
  .title('My List')
  .items([...])
  .views([
    S.view.component(CustomView).id('custom').title('Custom View')
  ])
  .overview(
    S.component(OverviewComponent).id('overview')
  )
```

Files modified:
- packages/sanity/src/structure/structureBuilder/List.ts
- packages/sanity/src/structure/types.ts
- packages/sanity/src/structure/panes/list/ListPane.tsx
- packages/sanity/src/structure/panes/list/ListPaneContent.tsx
- packages/sanity/src/structure/panes/list/ListPaneHeader.tsx
- packages/sanity/src/structure/structureResolvers/createResolvedPaneNodeStream.ts

Files created:
- packages/sanity/src/structure/panes/list/ListPaneContext.ts
- packages/sanity/src/structure/panes/list/useListPane.ts
- packages/sanity/src/structure/panes/list/ListHeaderTabs.tsx
- dev/test-studio/components/listViews/CustomListView.tsx
- dev/test-studio/components/listViews/ListOverview.tsx

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@vercel
Copy link

vercel bot commented Nov 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
page-building-studio Ready Ready Preview Comment Nov 7, 2025 0:10am
performance-studio Ready Ready Preview Comment Nov 7, 2025 0:10am
test-studio Ready Ready Preview Comment Nov 7, 2025 0:10am
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
e2e-studio Ignored Ignored Nov 7, 2025 0:10am
studio-workshop Ignored Ignored Nov 7, 2025 0:10am
test-next-studio Ignored Ignored Nov 7, 2025 0:10am

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

No changes to documentation

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

🧪 E2E Preview environment

🔑 Environment Variables for Local Testing

This is the preview URL for the E2E tests: https://e2e-studio-10mqumebw.sanity.dev

To run the E2E tests locally, you can use the following environment variables, then run pnpm test:e2e --ui to open the Playwright test runner.

💬 Remember to build the project first with pnpm build:e2e.

  SANITY_E2E_PROJECT_ID=ittbm412
  SANITY_E2E_BASE_URL=https://e2e-studio-10mqumebw.sanity.dev
  SANITY_E2E_DATASET="update depending the project you want to test (pr-11075-chromium-19153666932 || pr-11075-firefox-19153666932 )"
  SANITY_E2E_DATASET_CHROMIUM=pr-11075-chromium-19153666932
  SANITY_E2E_DATASET_FIREFOX=pr-11075-firefox-19153666932

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

🧪 E2E Preview environment

Waiting for preview deployment to finish…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

📊 Playwright Test Report

Download Full E2E Report

This report contains test results, including videos of failing tests.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

📊 Playwright Test Report

Waiting for E2E tests to finish…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

⚡️ Editor Performance Report

Deploying studio and running performance tests…

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

⚡️ Editor Performance Report

Deploying studio and running performance tests…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 44.53% 64606 / 145056
🔵 Statements 44.53% 64606 / 145056
🔵 Functions 49.42% 3228 / 6531
🔵 Branches 79.61% 12120 / 15224
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/sanity/src/structure/types.ts 0% 0% 0% 0%
packages/sanity/src/structure/panes/list/ListHeaderTabs.tsx 0% 0% 0% 0% 1-60
packages/sanity/src/structure/panes/list/ListPane.tsx 0% 0% 0% 0% 1-71
packages/sanity/src/structure/panes/list/ListPaneContent.tsx 0% 0% 0% 0% 1-193
packages/sanity/src/structure/panes/list/ListPaneContext.ts 0% 0% 0% 0% 1-12
packages/sanity/src/structure/panes/list/ListPaneHeader.tsx 0% 0% 0% 0% 1-48
packages/sanity/src/structure/panes/list/useListPane.ts 0% 0% 0% 0% 1-11
packages/sanity/src/structure/structureBuilder/List.ts 49.75% 57.77% 47.36% 49.75% 23-32, 64-86, 101, 103-104, 107-146, 223-224, 232-233, 239-240, 248-249, 255-256, 265-270, 274-279, 286-293, 298, 303-312, 316, 326, 329
packages/sanity/src/structure/structureResolvers/createResolvedPaneNodeStream.ts 0% 0% 0% 0% 1-475
Generated in workflow #45018 for commit 849a1b8 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants