-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template Parts: Avoid duplicate titles on creation #46996
Conversation
…to ensure that there is no duplicate title. If there is, add a suffix.
Size Change: +68 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
Flaky tests detected in d424584. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3879006808
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works 👍
The other option here would be to validate the inputs on submit, and alert the user if the chosen name is already in use.
I think this is probably better though as it eliminates any friction in the creation flow, and it's generally an edge case anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Thanks 👍 Will follow up with a PR to address converting and naming a group of blocks to a template part. |
What?
Fixes #42473. Do not allow duplicate titles for template parts when creating a new template part in the UI. Instead add an iterator suffix as is done with slugs.
Why?
See #42473 for images. Essentially we don't want users to have a huge list of template parts all with the same name in the UI. It becomes impossible to pick the correct one.
How?
I perform this on the client side at creation time, although I'm wondering if a filter on the PHP side would be a better approach? Interested in thoughts.
The same thing needs to happen on conversion of a group of blocks to a template part, this is not yet handled. This would mean needing to separate out the client side code to be used in two separate components. If this is switched to a PHP filter it would just happen automatically, everywhere.
Testing Instructions