Skip to content

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Jan 5, 2026

Description

Fixes GitHub issue #21223 where the "unpublished changes" indicator incorrectly shows on the default language variant when publishing a document with:

  • A culture-variant content type
  • An invariant BlockList property containing culture-variant blocks

Root cause: PublishedValue and EditedValue JSON strings differed due to:

  1. Different ordering of culture values within block items between FromEditor and MergePartialPropertyValueForCulture serialization paths
  2. The Udi property having different values (null vs computed umb://element/...) depending on whether the value is deserialized or constructed.

Solution:

  • Sort block item values by culture code before serialization in both paths to ensure consistent ordering.
  • Add [JsonIgnore] to BlockItemData.Udi to exclude this computed property from serialization.
    • As this property is obsolete and not used - other than for backward compatibility, see below - we can discard any value that might have been set via the BlockItemData constructor if we go through a serialization/deserialization path.
    • Other than

Handling Backward Compatibility

Adding [JsonIgnore] to BlockItemData.Udi to prevent serialization would break backwards compatibility with the legacy JSON format that uses udi instead of key to identify blocks. To resolve that I have updated JsonBlockValueConverter to manually extract the udi field from legacy JSON and convert it to the Key property during deserialization.

Testing

I've added an integration test that was initially failing before the work in this PR is applied, and after which is passes (Initial_Publish_All_Cultures_Should_Not_Mark_Content_As_Edited in BlockListElementLevelVariationTests.Publishing).

For manual testing, see the steps described in the linked issue (create culture-variant document with invariant Block List containing culture-variant blocks, save both cultures, publish all - verify no pending changes indicator appears)

I've also verified that taking a block list based document on Umbraco 13 and upgrading to this PR brings over the block data correctly, such that it can be viewed and edited in the backoffice.

…kList with culture-variant blocks (closes #21223)

When a document with a culture-variant content type has an invariant BlockList property containing culture-variant blocks, and you publish all languages for the first time, the content would incorrectly show as having unpublished changes.

The root cause was inconsistent JSON serialization order between EditedValue and PublishedValue. Two fixes were applied:

1. Sort block item values by culture before serialization in both `FromEditor` and `MergePartialPropertyValueForCulture` to ensure consistent ordering.

2. Add `[JsonIgnore]` to `BlockItemData.Udi` property since this computed property differs between save and publish paths.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 5, 2026 14:49
@AndyButland AndyButland changed the title Block editors: Fix false pending changes indicator for invariant BlockList with culture-variant blocks (closes #21223) Block editors: Fix false pending changes indicator for invariant block editor with culture-variant blocks (closes #21223) Jan 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a false "unpublished changes" indicator (GitHub issue #21223) that appeared when publishing documents with culture-variant content types containing invariant BlockList properties with culture-variant blocks for the first time. The root cause was inconsistent JSON serialization between the PublishedValue and EditedValue due to culture ordering differences and the obsolete Udi property being included in serialization.

Key Changes

  • Added culture-aware sorting to block item values to ensure consistent JSON serialization order across all serialization paths
  • Added [JsonIgnore] attribute to the obsolete BlockItemData.Udi property to prevent serialization inconsistencies
  • Added comprehensive regression test to verify the fix

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
BlockListElementLevelVariationTests.Publishing.cs Adds regression test that verifies content is not incorrectly marked as edited after publishing all cultures with invariant BlockList containing culture-variant blocks
BlockValuePropertyValueEditorBase.cs Implements sorting methods to order block item values by culture code, applied in MergePartialPropertyValueForCulture before serialization to ensure consistent JSON output
BlockEditorPropertyValueEditor.cs Applies culture sorting in FromEditor method before serialization to maintain consistency with the merge path
BlockItemData.cs Adds [JsonIgnore] to obsolete Udi property to prevent it from being serialized, eliminating another source of inconsistency (the property is already set to null by BlockEditorDataConverter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants