Skip to content
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

It's possible to create template parts with duplicate names #42473

Closed
jameskoster opened this issue Jul 15, 2022 · 3 comments · Fixed by #46996
Closed

It's possible to create template parts with duplicate names #42473

jameskoster opened this issue Jul 15, 2022 · 3 comments · Fixed by #46996
Assignees
Labels
[Block] Template Part Affects the Template Parts Block Needs Dev Ready for, and needs developer efforts

Comments

@jameskoster
Copy link
Contributor

jameskoster commented Jul 15, 2022

Description

When creating a template part, either manually or via one of the automatic flows like inserting a header pattern, it's possible for duplicate names to be used.

Step-by-step reproduction instructions

  1. Create a template part and give it a name
  2. Create another template part and give it the same name

Screenshots, screen recording, code snippet

Screenshot 2022-07-15 at 15 01 20

@jameskoster
Copy link
Contributor Author

jameskoster commented Jul 15, 2022

When creating manually, there should probably be some validation on the name input which prohibits the creation of template parts with duplicate names.

In the automatic flows, we might consider appending -1 to the end of the new template part name.

cc @WordPress/gutenberg-design

@jameskoster jameskoster added the Needs Design Feedback Needs general design feedback. label Jul 15, 2022
@paaljoachim
Copy link
Contributor

Adding a 1 or 2 etc at the end of the template part name would be similar to creating a folder etc on the computer and is something we are just used to seeing. Here is an example of creating two folders with the same name on OSX.

Screenshot 2022-07-16 at 11 12 19

So we could do the same thing as seen on OSX.

@jameskoster jameskoster added Needs Dev Ready for, and needs developer efforts and removed Needs Design Feedback Needs general design feedback. Needs Design Needs design efforts. labels Nov 1, 2022
@apeatling apeatling self-assigned this Jan 9, 2023
@apeatling
Copy link
Contributor

Confirmed this is still the case in trunk:

Screenshot 2023-01-09 at 12 11 45 PM

I'll work on a PR that will add an iterating trailing number to duplicate template part names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block Needs Dev Ready for, and needs developer efforts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants