Separated actions and edit functionality in the Pages Template DataForm field#73880
Conversation
|
👋 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. |
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
How this works in trunk: Screen.Recording.2025-12-12.at.09.45.13.movHow this works in this PR: Screen.Recording.2025-12-12.at.09.40.58.mov |
|
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:
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? |
|
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 |
|
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. |
|
Thanks for the explorations @jimjasson
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. |

What?
This is a pre-requisite for: #73036
As mentioned in this comment: #73036 (comment)
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
DataViewandPostActionsmenu.Why?
As mentioned above, DataForm fields should not support actions.
How?
reset-templateaction, which is only visible when a page has a custom template assigned.Files modified:
packages/fields/src/fields/template/template-edit.tsx- Removed dropdown menu, field now opens modal directlypackages/fields/src/actions/reset-template.tsx- New action implementationpackages/fields/src/actions/index.ts- Export new action.packages/editor/src/dataviews/store/private-actions.ts- Register action for pages.Testing Instructions
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
PostActionsmenu, even if I haven't saved the changed yet. In order for this action to appear on theDataViewsaction, 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?