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

Navigation Link block keeps reference of post ID it was created with after URL gets changed #67643

Open
fabiankaegy opened this issue Dec 5, 2024 · 4 comments · May be fixed by #68143
Open
Assignees
Labels
[Block] Navigation Link Affects the Navigation Link Block [Feature] Navigation Menus Any issue relating to Navigation Menus [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@fabiankaegy
Copy link
Member

When you add a new navigation link block it technically also adds the id/postTyoe of the post/page it is linking to. This is used determine the active variation etc.

<!-- wp:navigation-link {"label":"XXX","type":"page","id":123,"url":"http://xxx.xx/xxx/","kind":"post-type"} /-->

The problem is that there is no way to unlink that navigation link block from that original post that was selected. And the ID also stays there.

So if you go into an existing navigation, update all the links and labels and then at some point delete/unpublish the original post with the ID that is still in the attributes, the navigation item will not get shown on the frontend anymore. This is because core rightly so wants to not show draft posts in the navigation.

The solution here would be to remove the id attribute when the URL gets manually changed by the user

@fabiankaegy fabiankaegy added [Block] Navigation Link Affects the Navigation Link Block [Feature] Navigation Menus Any issue relating to Navigation Menus [Type] Bug An existing feature does not function as intended labels Dec 5, 2024
@fabiankaegy
Copy link
Member Author

@getdave curious to get your take on this one here 🤔 Do you think it would be fine to remove the id & postType attributes when the user manually updates the URL?

@getdave
Copy link
Contributor

getdave commented Dec 5, 2024

Closely connected to #18345 which is on the Tracking Issue.

Yes if a new value gets submitted then a new id should be set as an attribute 👍

@Andrew-Starr
Copy link

Just wanted to note that this also applies to the Navigation Submenu block, and also taxonomy objects in the 'kind' attribute.

@getdave
Copy link
Contributor

getdave commented Dec 6, 2024

In general the Link and Submenu blocks probably need to find ways to reuse the same core code. Duplicating features manually is challenging at best and at worst produces a lot of inconsistencies between the blocks.

@draganescu as a long time contributor to the Editor project, I wonder have you encountered any blocks which share code between them?

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Link Affects the Navigation Link Block [Feature] Navigation Menus Any issue relating to Navigation Menus [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants