Skip to content

Add lock icon styling for non-editable theme templates#72900

Open
harshbhonsle wants to merge 4 commits intoWordPress:trunkfrom
harshbhonsle:add/lock-icon-template-management
Open

Add lock icon styling for non-editable theme templates#72900
harshbhonsle wants to merge 4 commits intoWordPress:trunkfrom
harshbhonsle:add/lock-icon-template-management

Conversation

@harshbhonsle
Copy link
Contributor

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?

  • Modified packages/edit-site/src/components/page-templates/index.js to conditionally render a lock icon for non-editable templates.
  • Updated packages/edit-site/src/components/page-templates/style.scss to style the lock icon and tooltip.
  • Tooltip text: “This template cannot be edited.”

Testing Instructions

  1. Go to the WordPress dashboard.
  2. Navigate to Appearance > Editor.
  3. Click on "Templates" in the sidebar.
  4. Observe that non-editable templates display a lock icon.
  5. Hover over the icon to see the tooltip: “This template cannot be edited.”

Testing Instructions for Keyboard

  • Confirm that the lock icon is accessible and the tooltip appears on focus or hover.

Screenshots or screencast

|Before|

image |After| tempate-lock

@github-actions
Copy link

github-actions bot commented Nov 1, 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: harshbhonsle <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: nendeb <[email protected]>

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

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Feature] Templates API Related to API powering block template functionality in the Site Editor labels Nov 3, 2025
@harshbhonsle
Copy link
Contributor Author

Thanks for adding the labels, @t-hamano.
Could you please review this when you have a moment, or add someone from the Templates API team who’s responsible for this area?

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.tsx file and implement the same functionality as the PatternTitleView component.
  • Assign that title view to the render property here.

@harshbhonsle
Copy link
Contributor Author

Hi @t-hamano,

I’ve implemented the TemplateTitleView and integrated it with the template field as suggested.

Specifically:

  • Created packages/fields/src/fields/template-title/view.tsx to render the template title along with the lock icon for non-editable templates.
  • Updated templateTitleField (packages/fields/src/fields/template-title/index.ts) to assign TemplateTitleView to the render property. This ensures the title field now displays the lock icon for non-editable theme templates.
  • The lock icon includes a tooltip: “This template cannot be edited,” consistent with the design for pattern templates.

This aligns the template title field behavior with the pattern title implementation while providing a clear visual cue for non-editable templates.
Let me know if you have any feedback or if further adjustments are needed!

} );
const dateField = postTypeFields.find( ( field ) => field.id === 'date' );
const themeField = useThemeField();
const fields = useMemo( () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes are needed to this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the layout and structure here different from the pattern title view?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a <div> and <span> to position the lock next to the kebab menu. Without them, it appears next to the title. I can remove them if you want.
image

@harshbhonsle harshbhonsle force-pushed the add/lock-icon-template-management branch from 2b20c99 to 1b36efa Compare November 11, 2025 16:14
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 }>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted unnecessary changes to page-templates files and added className with corresponding style for template-title field as suggested.
@t-hamano

@t-hamano
Copy link
Contributor

@harshbhonsle, There are still two unexpected changes.

  • package.json
  • package-lock.json

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?

@jasmussen
Copy link
Contributor

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.

@harshbhonsle
Copy link
Contributor Author

@t-hamano, I tried to revert the unintended changes in package.json and package-lock.json by matching them to trunk. I ran git fetch upstream and git checkout upstream/trunk -- to revert the files. It’s possible that new dependencies were added to trunk, which is why package.json and package-lock.json are still showing changes.

@ellatrix
Copy link
Member

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.

@t-hamano t-hamano added the [Status] Blocked Used to indicate that a current effort isn't able to move forward label Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Templates API Related to API powering block template functionality in the Site Editor [Status] Blocked Used to indicate that a current effort isn't able to move forward [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WordPress 6.9 Added lock icon to template management

4 participants