Skip to content

Content Value Transformation: Clean out values when property-type variation transforms#21557

Merged
nielslyngsoe merged 6 commits intomainfrom
v17/bugfix/cleanup-values-when-propertytype-transforms
Jan 28, 2026
Merged

Content Value Transformation: Clean out values when property-type variation transforms#21557
nielslyngsoe merged 6 commits intomainfrom
v17/bugfix/cleanup-values-when-propertytype-transforms

Conversation

@nielslyngsoe
Copy link
Member

@nielslyngsoe nielslyngsoe commented Jan 28, 2026

Improves value transformation when property variation settings (such as varyByCulture) change while a content workspace is open. The main focus is on handling transitions between invariant and variant property types more robustly and efficiently.

Key improvements to value transformation logic:

  • Replaces the single-value transformation method (#transformValueForVariationChange) with a new batch-processing method (#transformValuesForVariationChanges)
  • Updated methods ensures handling of property variation changes:
    • For invariant → variant transitions, assigns the default language to the single invariant value.
    • For variant → invariant transitions, retains only values for the default language (or first available culture) and sets them as invariant.
    • Ensures values remain unchanged if no variation change is detected or if property type definitions are missing.

This is an addition and refactor of the work done in: #21293

Copilot AI review requested due to automatic review settings January 28, 2026 11:59
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 refactors the content value transformation logic to handle property variation changes more robustly. The main change replaces a single-value transformation approach with batch processing that groups values by property alias for more efficient handling of invariant ↔ variant transitions.

Changes:

  • Replaced #transformValueForVariationChange method with #transformValuesForVariationChanges for batch processing
  • When transitioning from variant to invariant, the code now consolidates values by keeping only the default language (or first available culture) and discarding other cultures
  • When transitioning from invariant to variant, all values are assigned the default language culture

Reviewed changes

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

File Description
content-detail-workspace-type-transform.controller.ts Refactored transformation method to process all values in batch, added grouping by alias, and implemented consolidation logic for variant→invariant transitions
content-detail-workspace-type-transform.controller.test.ts Updated existing test to reflect new behavior (only keeping default language value) and added 6 comprehensive new test cases covering edge cases like fallback culture selection, multiple properties, and segment preservation

Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

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

Code looks good, and this appears to work as expected for me. I tested with an invariant document, populated some properties, then opened an infinite editor window to change it to variant (with some properties shared and some variant). Then repeated in the other direction. In all cases a sensible update was made to the content so property values weren't lost.

The only issue I found - which I guess isn't intended to be fixed in this PR - is that if you change from invariant to variant or vice versa, the URL to the document changes, and so when you close the infinite editor window, you the underlying document is gone - you have a "not found" displayed and if you try to navigate away you get the dirty changes prompt.

This happens because the URL to the invariant document was /umbraco/section/content/workspace/document/edit/{id}/invariant but after changing to variant it becomes /umbraco/section/content/workspace/document/edit/{id}/en-US. So you have to navigate away, click to "discard changes" and come back to be able to see the updated properties and continue working with the document.

@nielslyngsoe nielslyngsoe merged commit c1b0672 into main Jan 28, 2026
27 of 28 checks passed
@nielslyngsoe nielslyngsoe deleted the v17/bugfix/cleanup-values-when-propertytype-transforms branch January 28, 2026 13:16
@nielslyngsoe
Copy link
Member Author

@AndyButland, well spotted, I also discovered that, and have it noted.

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.

3 participants