Skip to content

Commit

Permalink
fix new variant code when applied to themed (style) properties
Browse files Browse the repository at this point in the history
  • Loading branch information
bago committed Jun 1, 2022
1 parent 1aa6c7b commit 8cc8a97
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/js/converter/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function _makeNextVariantFunction(contentModel, t, variant) {
else pTarget = ko.utils.unwrapObservable(pTarget)[pParts[i4]];
}
if (typeof pTarget._defaultComputed != 'undefined') {
// maybe this is an acceptable condition and we could remove this warning
console.log("Found variant on a style property: beware variants should be only used on content properties because they don't match the theme fallback behaviour", variant);
pTarget = pTarget._defaultComputed;
}
Expand Down Expand Up @@ -256,7 +257,13 @@ var _makeComputedFunction = function(defs, contentModel, tobs) {
// create a _nextValue helper for boolean and select-options observable
var variants = _getValueVariants(val);
if (variants !== null) {
t[prop2]._nextValue = _nextValueFunction.bind(undefined, t[prop2], variants);
// When a _defaultComputed is defined the editing area will work on this observable,
// so we put the nextValue there
if (typeof t[prop2]._defaultComputed !== 'undefined') {
t[prop2]._defaultComputed._nextValue = _nextValueFunction.bind(undefined, t[prop2]._defaultComputed, variants);
} else {
t[prop2]._nextValue = _nextValueFunction.bind(undefined, t[prop2], variants);
}
}
}
}
Expand Down

0 comments on commit 8cc8a97

Please sign in to comment.