-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Which component is this issue related to?
Umbraco Commerce (Core)
Which Umbraco Commerce version are you using? (Please write the exact version, example: 10.1.0)
13.2.4
Bug summary
Bug: Price field overwritten in split view due to incorrect isPreview check
π Summary
When using split view in Umbraco, the price field in the second window overwrites the value in the first window.
This happens even though the price field does not vary by culture and should be ignored in the second/split-view editor.
The issue occurs because PriceController uses a captured isPreview variable instead of reading the live $scope.preview value. Inside updateModel(), $scope.preview correctly reflects split view state, but isPreview does not.
βοΈ Expected behavior
- In split view, the second editor should not update or overwrite price values.
$scope.previewshould correctly preventupdateModel()from writing values.
β Actual behavior
- In split view,
isPreviewis alwaysfalseat controller initialization. updateModel()therefore runs when it should not.- This causes the second editor to overwrite the first editorβs price values.
π Root Cause
Inside the controller:
var isPreview = $scope.preview; // Intended to be true in split viewHowever:
- At initialization,
$scope.previewis still false even in split view. - Inside
updateModel(),$scope.previewbecomes true, butisPreviewdoes not update.
Thus this condition is incorrect:
if (!isPreview && !vm.loading && vm.store && vm.prices)β Suggested Fix
Use $scope.preview directly inside updateModel():
- if (!isPreview && !vm.loading && vm.store && vm.prices)
+ if (!$scope.preview && !vm.loading && vm.store && vm.prices)This guarantees correct split-view behavior.
π₯ Reproduction Video
A demonstration of the issue:
https://tres.nl/media/temp/video.mp4
π Code Reference (with fix highlighted)
function PriceController($scope, $routeParams, ucStoreResource,
ucCurrencyResource, ucUtils, ucRouteCache)
{
var compositeId = ucUtils.parseCompositeId($routeParams.id);
var storeId = compositeId.length > 1 ? compositeId[0] : null;
var currentOrParentNodeId = compositeId.length > 1 ? compositeId[1] : compositeId[0];
var isDocTypeEditorPreview = $routeParams.section == "settings" && $routeParams.tree == "documentTypes";
var isPreview = $scope.preview;
var vm = this;
vm.model = $scope.model;
vm.loading = true;
vm.store = null;
vm.prices = null;
vm.options = {
fraction: !(($scope.model.config?.fraction ?? null) === null) ? $scope.model.config?.fraction : 2
};
vm.updateModel = function () {
// FIX APPLIED HERE βββ
if (!$scope.preview && !vm.loading && vm.store && vm.prices)
{
var value = {};
vm.prices.forEach(function (price) {
if (price.value !== "" && !isNaN(price.value)) {
value[price.currencyId] = price.value;
}
});
if (_.isEmpty(value))
value = undefined;
var oldValue = $scope.model.value;
$scope.model.value = value;
$scope.model.onValueChanged($scope.model.value, oldValue);
}
};
}Specifics
No response
Steps to reproduce
See video
Expected result / actual result
No response
Dependencies
No response
This item has been added to our backlog AB#62133