Variables only use example & fallback values when using structured format
Taiwar opened this issue · 3 comments
This issue broke existing components with variables that worked. Initially we thought it was a misconfiguration or missed breaking change in our project, but then we updated out ditto dependencies and used an example config from the cli readme and it still occurs.
Example code
package.json
{
...
"@dittowords/cli": "^3.9.0",
"ditto-react": "^1.4.0",
...
}
config.yml
sources:
components:
enabled: true
format: structured
variants: true
ditto-component-library__base.json
{
...
"filter.condition.hover": {
"name": "Filter/Condition/Hover",
"text": "Grade {{Grade_GradingLogic}}; {{Kilometer}} km; {{Percentage}} %",
"status": "NONE",
"folder": null,
"variables": {
"Grade_GradingLogic": {
"example": 3,
"fallback": 3.5,
"__type": "number"
},
"Kilometer": {
"example": 15,
"fallback": 21,
"__type": "number"
},
"Percentage": {
"example": 12,
"fallback": 14,
"__type": "number"
}
},
variants: {...}
}
example.tsx
<Ditto
componentId="filter.condition.hover"
variables={{
// The actual code here uses variables of course, but even fixed values don't work
Grade_GradingLogic: 2,
Kilometer: 5,
Percentage: 34
}}
/>
Result
"Note 3; 15 km; 12 %"
Expected result
"Note 2; 5 km; 34 %"
If I manually remove the "example"
attributes of the variables, ditto-react then uses the "fallback"
values. If I remove those too, the variables are replaced with undefined
, even though I define them in <Ditto ... />
.
For our project, this issue is also related to #29 as neither of these formats support the core features we use anymore (structured
doesn't work with variables, flat
doesn't work with plurals).
Hi @Taiwar. I've confirmed this is a reproducible issue and am working on a fix. Thank you for reporting the bug!
Can confirm, v1.4.1 fixes the issue. Thanks!