deephaven / web-client-ui

Deephaven Web Client UI
Apache License 2.0
29 stars 31 forks source link

fix: Proxy model not setting defined values in parent class #2187

Closed mattrunyon closed 2 months ago

mattrunyon commented 2 months ago

Something I noticed when working on dh.ui databars. I don't think this currently causes any issues in DHC, but it could. If we defined a member field in the proxy model and then set the value, we could end up with the wrong values.

This is only an issue if we directly set a public member. In the current proxy model, we only set via setField type functions, so things seem to be fine. Inside of class definitions the proxy is skipped (since the proxy is just returned from the ctor).

This change makes setting a member defined in the proxy class work even if you try to do it on the proxy object.

class ProxyModel {
  myField = 4
}

test = new ProxyModel();
test.myField; // 4
test.model.myField; // undefined

test.myField = 5;
test.myField; // 4 - WRONG
test.model.myField; // 5
codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 46.67%. Comparing base (a257296) to head (cb7cb26).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2187 +/- ## ======================================== Coverage 46.66% 46.67% ======================================== Files 692 692 Lines 38629 38630 +1 Branches 9814 9630 -184 ======================================== + Hits 18028 18029 +1 - Misses 20548 20590 +42 + Partials 53 11 -42 ``` | [Flag](https://app.codecov.io/gh/deephaven/web-client-ui/pull/2187/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deephaven) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/deephaven/web-client-ui/pull/2187/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deephaven) | `46.67% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=deephaven#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.