-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Block editors: Fix false pending changes indicator for invariant block editor with culture-variant blocks (closes #21223) #21292
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
base: main
Are you sure you want to change the base?
Conversation
…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>
There was a problem hiding this 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 obsoleteBlockItemData.Udiproperty 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) |
...ion/Umbraco.Infrastructure/PropertyEditors/BlockListElementLevelVariationTests.Publishing.cs
Outdated
Show resolved
Hide resolved
…yEditors/BlockListElementLevelVariationTests.Publishing.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…rison' of https://github.com/umbraco/Umbraco-CMS into v17/bugfix/standardise-block-values-for-is-edited-comparison
…nd legacy format, to correctly fix previously failing integeration and E2E tests.
Description
Fixes GitHub issue #21223 where the "unpublished changes" indicator incorrectly shows on the default language variant when publishing a document with:
Root cause:
PublishedValueandEditedValueJSON strings differed due to:FromEditorandMergePartialPropertyValueForCultureserialization pathsUdiproperty having different values (nullvs computedumb://element/...) depending on whether the value is deserialized or constructed.Solution:
[JsonIgnore]toBlockItemData.Udito exclude this computed property from serialization.BlockItemDataconstructor if we go through a serialization/deserialization path.Handling Backward Compatibility
Adding
[JsonIgnore]toBlockItemData.Udito prevent serialization would break backwards compatibility with the legacy JSON format that usesudiinstead ofkeyto identify blocks. To resolve that I have updatedJsonBlockValueConverterto manually extract theudifield from legacy JSON and convert it to theKeyproperty 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_EditedinBlockListElementLevelVariationTests.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.