-
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
When duplicating a Navigation or Template Part block, it's not clear why changing one changes the other #30276
Comments
I have a similar bug with the framework I wrote. Here's what happens. If I have a block "A", that doesn't have repeater fields inside it. And if I then duplicate that block, and edit the new block (that's a copy of the main block), I don't have any bugs. Each updates for itself. But. In the case of block "B", which has a repeater field inside it, this is what happens.
I hope I am making sense here. Here's the video of the bug: |
I am updating this issue because I am experiencing the same with the navigation block. |
I tested this with the navigation block and can confirm. Ideally on duplication, an independent copy of blocks should be created. |
Any news about whether this bug is on the roadmap for being fixed? It's a pretty major bug. |
Noting that this has come up as a piece of feedback with the FSE Outreach Program's latest All Things Media exploration as a point of confusion (twice):
|
So what's happening here is that a navigation block may be represented by content in a When we copy the block, we're copying the ref attribute, so edits on child blocks will be reflected in both instances.
One way of solving this is adding an action like a deepCopy, where if we see a ref attribute, we can create a new block container and copy its children. Note that in this scenario block children are not available as part of innerBlocks, but can still be queried: @annezazu was there a similar issue for Reusable Blocks? They're represented in a similar way, with the block looking like:
|
I don't see a similar issue open for reusable blocks but can replicate the problem. |
@annezazu isn't this a feature in the case of reusable blocks though? |
Honestly, I'm not sure :) In my mind, using "duplicate" should create a copy that is distinct from the original whereas "copy" should result in the same reusable block being made. In this case, there is no difference between duplicate and copy currently with reusable blocks based on my quick testing. |
So after playing around with this last week, I think this is a little tricker than I thought to solve this for the general case. (We can of course temporarily put in a fix for navigation/templates if this is particularly urgent.) Some questions that I found while exploring this:When the "truth" of a block is no longer fully serialized, what does it mean to copy or duplicate it?Many of the API factory functions expect that the block is fully represented by block attributes and inner block contents. When we point at a post reference or slug, should these abstractions know about these properties? Should we standardize externalized references in blocks similar to using an See also the following links, where folks are exploring marking certain block attributes as having specific roles: cc @dmsnell @stacimc @noisysocks @youknowriad @ntsekouras User Experience/IntentionDepending on the block we might expect that we have a deep copy of its contents (edits don't shadow the original), that they do edit the original, or that folks should have a choice in the behavior. Describing this behavior succinctly will probably be difficult. Block examplesFor reference here's what these sorts of blocks look like, when they reference external sources: Navigation Example
Template Example
Reusable Block
Compare this with another type of block like heading which is self-contained:
|
It is expected, but it feels unexpected. Reusable blocks are helped by their name. It's expected that if you have a reusable "thing" and you edit it, the edit will be visible across all the places where you "reused". But for the navigation block it's unclear, only from the "Select menu" toolbar item that editing it's copy changes the "original". But I think @noisysocks has a point in that maybe the problem is the UI not changing how copy/duplicate works. |
when asked to think through this I was unable to find a clear way to express the expectations. whether we assume the clones impact their source or the opposite I find that there are instant problems, problems probably not easily solvable by choosing for someone how the clone should relate. we could give people the choice and avoid the questions about that by asking "You are duplicating this block/template; would you like for edits made to this copy to also change the block it came from? [Changes affect both blocks] [Changes only affect this copy]" |
Worth noting too that reusable blocks have a few UI affordances which are intended to convey this:
|
that's good, @noisysocks, but in the context of menus I would imagine there's a great need to not only convey when a block is a linked clone but also when to convey that it's independent. it seems like a very reasonable expectation that if you clone an entire menu and then change an item in one submenu, then the menu from which it came also gets the update. I'm imagining a site with a separate menu for each zone/group/category of the site, but all someone wants to do is move around or extend the base menu. suddenly realizing that they have to go around and make the same change to ten different menus because they disconnected when duplicating could be a big bummer. something that's nice about giving choice I think. those blocks could remain linked duplicates until someone wants to make a change and then they could be informed about what they're about to do, vs. relying on someone to know how the system works before investing hours into their site and figuring out after all that time that they've messed things up and have to go through all the pages and check if they duplicated the same edits, or the other way, that they thought they were making separate edits but every page only shows the latest changes they made on some other unrelated page. |
The original behavior continues to be a problem, even if it was intended. I have 8 templates. One of the differences is that each template has it's own sidebar with a menu, where only one menu item is the same for all templates. The menu design is the same, it has the same class names to add some CSS for styling. |
I think the copy and duplicate options should be removed. |
How's this issue? Is there any fix? Cause I'm encountering this bug right now. |
2023 and this great "feature" is still there. Unbelievable... |
I'm still running into this issue today. My work-around as a non-coder is to save the block as a reusable section. Any duplication method I tried (saving/refreshing/renaming new feature to mismatch original) always resulted in making changes to the original. Posting for any other folks who find themselves here through a google search. ;) |
Any updates on this? |
No one has been able to present any ideas and suggestions for how to make it easier for users, so no. |
The biggest issue for menus is that the currently sekected menu is practically invisible. |
This is not only while you are trying to duplicate the Navigation, but when trying to add a new Navigation block. Possibly I am doing something wrong, and you should only have one Navigation per Header, but this is frustrating; I need a couple of them. |
The navigation block and the menu are two separate things. A menu can be used in any number of navigation blocks. If you edit a menu, the menu content is updated everywhere where that menu is used. If you add a new navigation block a menu may be assigned by default. If you want the content to be different you need to select This is also how it worked with the classic menu, where you needed to select menu locations and assign your menu to the header footer, primary etc etc. The menu remains the menu, the navigation block is the menu location. |
Description
It seems that when you duplicate a template part, it does not automatically receive a unique identifier?
In the site editor, when I duplicate a template part:
-I can not change the title of the copy without using "Update design." #29844
-After changing the title of the template part and updating, the template parts are separate.
Step-by-step reproduction instructions
Please list the steps needed to reproduce the bug. For example:
Expected behaviour
I expected the copied template part to be its own unique copy with a new, random slug/title
Actual behaviour
The template part is not "unique" until the title has been updated by the user and the changes saved.
Screenshots or screen recording (optional)
template-part.mp4
WordPress information
Device information
The text was updated successfully, but these errors were encountered: