Skip to content

OBPIH-7231 Fix storing internal locations filter when refreshing a page#5215

Merged
awalkowiak merged 1 commit intorelease/0.9.4from
OBPIH-7231
Apr 18, 2025
Merged

OBPIH-7231 Fix storing internal locations filter when refreshing a page#5215
awalkowiak merged 1 commit intorelease/0.9.4from
OBPIH-7231

Conversation

@kchelstowski
Copy link
Collaborator

✨ Description of Change

Link to GitHub issue or Jira ticket:

Description:


📷 Screenshots & Recordings (optional)

@kchelstowski kchelstowski self-assigned this Apr 17, 2025
@github-actions github-actions bot added the domain: frontend Changes or discussions relating to the frontend UI label Apr 17, 2025
.map(({ id, label }) => ({
id, label, name: label, value: id,
.map(({ id, label, name }) => ({
id, label: label ?? name, name: name ?? label, value: id,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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:
Screenshot from 2025-04-17 14-13-31

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."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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
Copy link

codecov bot commented Apr 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 8.12%. Comparing base (f464859) to head (a08c15d).
Report is 10 commits behind head on release/0.9.4.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@awalkowiak awalkowiak merged commit acf988d into release/0.9.4 Apr 18, 2025
8 checks passed
@awalkowiak awalkowiak deleted the OBPIH-7231 branch April 18, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: frontend Changes or discussions relating to the frontend UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants