Add lock icon styling for non-editable theme templates#72900
Add lock icon styling for non-editable theme templates#72900harshbhonsle wants to merge 4 commits intoWordPress:trunkfrom
Conversation
|
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. |
|
Thanks for adding the labels, @t-hamano. |
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Perhaps it would be easier to just mimic the implementation of patternTitleField? That is,
- Create
packages/fields/src/fields/template-title/view.tsxfile and implement the same functionality as thePatternTitleViewcomponent. - Assign that title view to the
renderproperty here.
|
Hi @t-hamano, I’ve implemented the TemplateTitleView and integrated it with the template field as suggested. Specifically:
This aligns the template title field behavior with the pattern title implementation while providing a clear visual cue for non-editable templates. |
| } ); | ||
| const dateField = postTypeFields.find( ( field ) => field.id === 'date' ); | ||
| const themeField = useThemeField(); | ||
| const fields = useMemo( () => { |
There was a problem hiding this comment.
No changes are needed to this file.
There was a problem hiding this comment.
Ok, I will remove the comments and revert the file back to the original code.
| const isLocked = !item.is_custom; | ||
|
|
||
| return ( | ||
| <div className="page-template-title-wrapper"> |
There was a problem hiding this comment.
Why is the layout and structure here different from the pattern title view?
2b20c99 to
1b36efa
Compare
t-hamano
left a comment
There was a problem hiding this comment.
@harshbhonsle, can you revert the changes to these files? We don't need to change these files.
- packages/edit-site/src/components/page-templates/index.js
- packages/edit-site/src/components/page-templates/style.scss
- package-lock.json
- package.json
| const isLocked = ! item.is_custom; | ||
|
|
||
| return ( | ||
| <BaseTitleView item={ item }> |
There was a problem hiding this comment.
| <BaseTitleView item={ item }> | |
| <BaseTitleView item={ item } className="fields-field__template-title"> |
Then, create a packages/fields/src/fields/template-title/style.scss file and write the following style:
.fields-field__template-title span:first-child {
flex: 1;
}There was a problem hiding this comment.
Reverted unnecessary changes to page-templates files and added className with corresponding style for template-title field as suggested.
@t-hamano
|
@harshbhonsle, There are still two unexpected changes.
Please see the Files changed tab to see what files are actually changed. @ellatrix @WordPress/gutenberg-design, We're trying to add lock icons to built-in (theme-provided) templates, but what do you think? |
|
Thanks for the ping. In short, lock icon for files that can't be edited seems fine. There are some aspects to the feature itself that I'd love to revisit. When I went deep on it recently, there were some aspects of it I could see improved, and I'd love to work with folks in the 7.0 phase to improve this. Some of the flow issues I encountered were related to editing a newly created, but not activated, template, then clicking the site logo to back, and being on the "Active templates" section. While I really need to go more deep on the mechanisms, a loose hunch is that splitting active away from created might not be necessary. Whether that leaves room for lock icons is not fully clear to me yet. |
|
@t-hamano, I tried to revert the unintended changes in |
|
Let's please wait with any further changes to template activation. It was reverted for 6.9 and will be put behind an experiment first in #73252. The current UI won't stay. |

What?
Closes #72863
Adds a lock icon to non-editable theme templates in the Site Editor, along with a tooltip to clarify that these templates cannot be edited directly.
Why?
In WordPress 6.9, the template management flow requires users to duplicate a theme template before editing. This change from previous behavior (where templates could be edited directly) may confuse users. Adding a lock icon helps visually distinguish non-editable templates and aligns with the styling used for pattern templates.
How?
packages/edit-site/src/components/page-templates/index.jsto conditionally render a lock icon for non-editable templates.packages/edit-site/src/components/page-templates/style.scssto style the lock icon and tooltip.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
|Before|