Skip to content

Conversation

@youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Jan 30, 2026

What?

Adds a new onReset prop to the DataViews component that enables a centralized Reset button in the view config dropdown. This replaces the ad-hoc reset buttons previously scattered across consumer pages.

Why?

Previously, each page that used useView had to implement its own "Reset view" button in the Page actions area. This led to:

  • Duplicated code across multiple components
  • Inconsistent placement and behavior
  • The reset functionality not being discoverable within the DataViews UI

How?

The new onReset prop accepts three values:

Value Meaning UI Behavior
undefined No persistence support No reset button rendered
false Persistence supported but view not dirty Disabled "Reset" button
() => void Callback to reset the view Active "Reset" button + blue dot on cog icon

Screenshot

Screenshot 2026-01-30 at 3 18 43 PM

The screenshot shows:

  • Blue dot indicator on the cog icon when the view is modified
  • Reset button in the dropdown header (next to "Appearance" title)

Testing Instructions

  1. Go to Pages, Posts, Templates, or Patterns in the Site Editor
  2. Modify the view (change sort, items per page, etc.)
  3. Observe the blue dot appears on the cog icon
  4. Open the view config dropdown
  5. Click "Reset" to restore the default view
  6. Verify the blue dot disappears after reset

Files Changed

  • packages/dataviews/src/components/dataviews-context/index.ts - Add onReset to context type
  • packages/dataviews/src/dataviews/index.tsx - Add onReset prop
  • packages/dataviews/src/components/dataviews-view-config/index.tsx - Add Reset button and blue dot indicator
  • packages/dataviews/src/components/dataviews-view-config/style.scss - Add styles
  • packages/edit-site/src/components/post-list/index.js - Use new prop, remove old button
  • packages/edit-site/src/components/page-templates/index.js - Use new prop, remove old button
  • packages/edit-site/src/components/page-patterns/index.js - Use new prop, remove old button
  • packages/edit-site/src/components/page-templates/index-legacy.js - Use new prop, remove old button

🤖 Generated with Claude Code

Adds a new `onReset` prop to the DataViews component that enables a centralized Reset button in the view config dropdown. This replaces the ad-hoc reset buttons previously scattered across consumer pages.

The prop accepts three values:
- `undefined`: No persistence support, no reset button rendered
- `false`: Persistence supported but view not dirty, shows disabled Reset button
- `() => void`: Callback to reset the view, shows active Reset button and blue dot indicator on cog icon

Changes:
- Add `onReset` prop to DataViews component and context
- Add Reset button in view config dropdown header (next to "Appearance" title)
- Add blue dot indicator on cog icon when view is modified
- Remove standalone reset buttons from post-list, page-templates, page-patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Jan 30, 2026

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Edit Site, [Package] DataViews.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

1 similar comment
@github-actions
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions github-actions bot added [Package] Edit Site /packages/edit-site [Package] DataViews /packages/dataviews labels Jan 30, 2026
@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: youknowriad <youknowriad@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

youknowriad and others added 2 commits January 30, 2026 15:17
Remove ad-hoc reset buttons from Page actions in routes files
and use the new onReset prop on DataViews component instead.

Files updated:
- routes/post-list/stage.tsx
- routes/template-part-list/stage.tsx
- routes/template-list/stage-activation.tsx
- routes/template-list/stage-legacy.tsx
- routes/pattern-list/stage.tsx
- routes/navigation-list/stage.tsx

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] DataViews /packages/dataviews [Package] Edit Site /packages/edit-site

2 participants