From 7b6ac8d5a2c2ae3de969c09b9bbba707bdb8956e Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 25 Mar 2024 11:35:13 +0400 Subject: [PATCH] Navigation: Avoid content loss when only specific entity fields are edited (#60071) Co-authored-by: Mamaduka Co-authored-by: jsnajdr Co-authored-by: annezazu --- packages/block-library/src/navigation/index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 1f623f4a158c59..49c4c67969191d 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -1520,6 +1520,14 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) { return $post; } + /** + * Skip meta generation when consumers intentionally update specific Navigation fields + * and omit the content update. + */ + if ( ! isset( $post->post_content ) ) { + return $post; + } + /* * We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into * all anchor blocks. For the root level, we create a mock Navigation and extract them from there.