force icon indicating copy to clipboard operation
force copied to clipboard

chore: second part of defaulting to save address.

Open oxaudo opened this issue 1 year ago • 5 comments

This is a second case I found that should fix https://artsyproduct.atlassian.net/browse/EMI-1939

It's a bit roundabout way to fix it but I believe it's a proper condition to call this useEffect regardless of this bug even. But looks like it works here because when the last address deleted on the page the length of addresses change and the previous case that I fixed (default to save address when address is present on the order but there is no addresses in context - default to save address).

It's all a bit confusing but seems to work. Also not sure how to test any of this stuff cause the setup is pretty complicated. But maybe can tested with integration run after.

oxaudo avatar Aug 23 '24 07:08 oxaudo

#144 Bundle Size — 9.51MiB (+0.01%).

15c5a76(current) vs 2682a9f main#143(baseline)

[!WARNING] Bundle contains 45 duplicate packages – View duplicate packages

Bundle metrics  Change 5 changes Regression 1 regression Improvement 1 improvement
                 Current
#144
     Baseline
#143
Regression  Initial JS 4.32MiB(~+0.01%) 4.32MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 16.87% 0.93%
Change  Chunks 143(+0.7%) 142
Change  Assets 146(+0.69%) 145
No change  Modules 5551 5551
Improvement  Duplicate Modules 379(-0.26%) 380
No change  Duplicate Code 4.78% 4.78%
No change  Packages 292 292
No change  Duplicate Packages 42 42
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#144
     Baseline
#143
Improvement  JS 9.3MiB (~-0.01%) 9.3MiB
Regression  Other 215.22KiB (+0.6%) 213.94KiB

Bundle analysis reportBranch oxaudo/saved_addressProject dashboard


Generated by RelativeCIDocumentationReport issue

relativeci[bot] avatar Aug 23 '24 07:08 relativeci[bot]

I still need to confirm this works but I have a fix for EMI-1944 which I think might achieve the same result: https://github.com/artsy/force/compare/erik.emi1944-clear-address-on-delete

What do you think? This way the value would be set when the form resets.

erikdstock avatar Aug 26 '24 22:08 erikdstock

@erikdstock - I think your suggestion is legit as well but probably can be done in parallel. Both of those changes are legit I think. The effect in SavedAddresses here depends on savedAddresses.length and context stuff and should be rerun if any of those change. I beieve we added those at some point with some bug fix but forgot to update run dependency.

oxaudo avatar Aug 27 '24 12:08 oxaudo

@erikdstock - I think your suggestion is legit as well but probably can be done in parallel. Both of those changes are legit I think. The effect in SavedAddresses here depends on savedAddresses.length and context stuff and should be rerun if any of those change. I beieve we added those at some point with some bug fix but forgot to update run dependency.

My thinking is this:

  • The change I made uses the result of getInitialValues() in FulfillmentDetails, outside of SavedAddresses. That function does return the default saveAddress: true
  • If the length of savedAddresses becomes zero, responsibility for the address form is returned to the no-saved-address shipping form (shippingFormMode === 'new_address')
  • This responsibility makes sense higher up in the component tree, in the FulfillmentDetails component & at the same point that we change the mode.

Since I just did that at the end of the day yesterday I'd like to test whether it works first, but maybe there is some bug as you mentioned that this change is still worth it. Maybe we could talk through it?

erikdstock avatar Aug 27 '24 13:08 erikdstock

Happy to merge your change first and see what's still off if anything. Happy to chet as well but probably not now as my connection here is so crappy and electricity is on/off today.

oxaudo avatar Aug 27 '24 15:08 oxaudo