OBPIH-7231 Fix storing internal locations filter when refreshing a page#5215
OBPIH-7231 Fix storing internal locations filter when refreshing a page#5215awalkowiak merged 1 commit intorelease/0.9.4from
Conversation
| .map(({ id, label }) => ({ | ||
| id, label, name: label, value: id, | ||
| .map(({ id, label, name }) => ({ | ||
| id, label: label ?? name, name: name ?? label, value: id, |
There was a problem hiding this comment.
there was a problem that the internaLocations endpoint doesn't return label property, whereas every console.log, even console.log written directly under the fetching method, was eventually returning objects with label property, whereas while mapping them, the label was undefined 🤔
It was misleading in the debugging, hence I even asked GPT - it turned out that JS does some quirk with console.log, when we mutate an object later on:

This is why I prefer immutable approach in programming.
FYI: console.table was returning the real value, not the "If the object is later mutated (like by a component or somewhere else in your code), it reflects that mutation even in earlier logs."
There was a problem hiding this comment.
The real mutating happens in the Select compoment in the mapOptions method:
mapOptions(values) {
return (_.map(values, (value) => {
const newValue = value;
if (typeof value === 'string') {
return { value, label: value };
}
if (value.options) {
newValue.options = this.mapOptions(value.options);
}
if (value && this.props.labelKey && !value.label) {
newValue.label = value[this.props.labelKey];
}
if (value && this.props.valueKey && !value.value) {
newValue.value = value[this.props.valueKey];
}
return newValue;
}));
}so even if you added here something like:
newValue.test = '123';the console.log that would be put directly under fetching method, would already log the objects with test property 🤯
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## release/0.9.4 #5215 +/- ##
==================================================
- Coverage 8.16% 8.12% -0.05%
+ Complexity 948 940 -8
==================================================
Files 638 638
Lines 43221 43244 +23
Branches 10506 10511 +5
==================================================
- Hits 3529 3512 -17
- Misses 39153 39195 +42
+ Partials 539 537 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
✨ Description of Change
Link to GitHub issue or Jira ticket:
Description:
📷 Screenshots & Recordings (optional)