Four51 / CustomSolutions

Custom Solutions
7 stars 15 forks source link

Minicart -- Race condition occasionally hides it #59

Open bhartvigsen opened 5 years ago

bhartvigsen commented 5 years ago

I noticed that occasionally the minicart disappears, it appears to be somehow related to viewport size but it's clearly a race condition. I'm not sure of the root cause, but this line:

<div ng-show="currentOrder && cartCount && !isInPath(\'order/\')">

Is the symptom. Occasionally pages will load and "cartCount" is undefined. It's a race condition that occurs earlier in the page load, and if "cartCount" is not set, it will never be set for that page load.

I'm currently using this line instead:

<div ng-show="currentOrder || cartCount">

Which works, however it's probably not the best solution. The proper fix would be to resolve why "cartCount" is sometimes failing to set on pageload. For some reason the issue is more likely to occur when my viewport is roughly 1096px wide, but it doesn't always happen. I found I could trigger the issue by moving my viewport around the 1096 mark and doing a hard refresh. If I resize, refresh, resize, refresh, etc, I'm able to somewhat reliably reproduce the issue.