Skip to content

Separated actions and edit functionality in the Pages Template DataForm field#73880

Closed
jimjasson wants to merge 1 commit intoWordPress:trunkfrom
jimjasson:tweak/create-use-default-template-action-for-pages
Closed

Separated actions and edit functionality in the Pages Template DataForm field#73880
jimjasson wants to merge 1 commit intoWordPress:trunkfrom
jimjasson:tweak/create-use-default-template-action-for-pages

Conversation

@jimjasson
Copy link
Copy Markdown

@jimjasson jimjasson commented Dec 10, 2025

What?

This is a pre-requisite for: #73036

As mentioned in this comment: #73036 (comment)

[...] actions in DataForm are out of scope for now, so this means that:

  • the template field opens a modal to change the template
  • there's a new "reset template" action that is visible in dataviews, and also accesible via the form title

Based on the above, this PR separates the edit functionality from actions in the Pages Template field. The field now directly opens the template selection modal, while the "Reset template" action is moved to the Pages DataView and PostActions menu.

Why?

As mentioned above, DataForm fields should not support actions.

How?

  • Moved "Use default template" functionality to a dedicated reset-template action, which is only visible when a page has a custom template assigned.
  • Updated the edit functionality of the template field. Clicking the template field value directly now opens the "Change template" modal.

Files modified:

  • packages/fields/src/fields/template/template-edit.tsx - Removed dropdown menu, field now opens modal directly
  • packages/fields/src/actions/reset-template.tsx - New action implementation
  • packages/fields/src/actions/index.ts - Export new action.
  • packages/editor/src/dataviews/store/private-actions.ts - Register action for pages.

Testing Instructions

  1. Go to Site Editor > Pages.
  2. Click on a specific page and open the Details sidebar:
Markup on 2025-12-10 at 16:07:45
  1. Click on the Template field.
  2. Notice that the modal to change the Template shows up.
  3. Pick a new template.
  4. Open the Actions menu:
Markup on 2025-12-10 at 16:09:08
  1. Notice that there is a Reset template action.
  2. Click it.
  3. Ensure that the template is reset.
  4. Confirm that the Reset template action is no longer visible.
  5. Once again click to select a custom template, but this time save it.
  6. Go to the Pages list and click on the Actions menu in the DataView.
  7. Notice that there is a Reset template action.
  8. Click it.
  9. Ensure that the template is reset.

Screenshots or screencast

Screen.Capture.on.2025-12-10.at.16-11-40.mov

Question for the reviewer

When I change the Template for a page, then the Reset template action becomes automatically available in the PostActions menu, even if I haven't saved the changed yet. In order for this action to appear on the DataViews action, though, I need to first save the new template option.

Is this expected? If not, is there an obvious way I am missing to make the DataViews action use the edited entity to validate if an action is eligible for the entity? If this is more challenging, could we leave it for a follow-up PR?

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 10, 2025
@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @jimjasson! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@jimjasson jimjasson marked this pull request as ready for review December 10, 2025 14:36
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 10, 2025

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: jimjasson <jasonkytros@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>

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

@oandregal oandregal added [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Enhancement A suggestion for improvement. labels Dec 12, 2025
@oandregal
Copy link
Copy Markdown
Member

How this works in trunk:

Screen.Recording.2025-12-12.at.09.45.13.mov

How this works in this PR:

Screen.Recording.2025-12-12.at.09.40.58.mov

@jameskoster
Copy link
Copy Markdown
Contributor

The empty modal in @oandregal's video is very confusing. I think we need a better solution for when there are no templates to display in the modal.

It's a real shame we need the 'reset' action at all, I think it would be better to include the default template as an option in the modal (which would also solve the empty modal situation), but I understand it's technically challenging. Is that still the case?

If we can't show the default template as a preview, maybe we can just include a Reset button in the modal, styled to look like roughly a preview? A quick mockup:

modal

This would allow us to remove the 'Reset template' action from the actions menu as well, which I think is a good idea because it's a relatively uncommon workflow—showing it in the menu permanently might draw unnecessary attention.

WDYT?

@jimjasson
Copy link
Copy Markdown
Author

Hey @jameskoster,

Thank you for the great feedback!

The purpose of this PR is to remove the DataForm actions from the edit value in order to unblock the work we are doing here: #73036

I agree that the experience of the "Choose a template" modal could be improved, especially to better handle the case when there aren't any templates to choose from. However, since this is already the behavior in trunk, I propose that we handle additional improvements in follow-up PRs. How does this sound? I can open an issue with the proposed design you created.

@jameskoster
Copy link
Copy Markdown
Contributor

I'll defer to @oandregal on that, but I suppose it's reasonable given the editor Inspector isn't using DataForm yet, and Quick Edit is still experimental.

@oandregal
Copy link
Copy Markdown
Member

Thanks for the explorations @jimjasson

The purpose of this PR is to remove the DataForm actions from the edit value in order to unblock the work we are doing here: #73036

I suggested this, and seeing what the flow ends up being, I'm no longer sure it's a good idea to change it.

Over at #73036 we are introducing a dedicated pencil icon for the panel layout. However, fields can chose to render in a different layout, which is what the featured media and the template fields do in QuickEdit: they render using the regular layout (form).

@jameskoster what do you think of leaving template as it is for now and focus on shipping the pencil improvements first? We can revisit the template field later if it is too confusing. I'm assuming the media field is not an issue because it's obviously different than the others.

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

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants