瀏覽代碼

Merge pull request #16409 from overleaf/dp-fix-group-pricing-after-back-button-pressed

Update group plan pricing modal after the page has fully loaded

GitOrigin-RevId: 03e2ea642b38d6e2e208683b0cb68a817a5873c8
David 2 年之前
父節點
當前提交
f6b7b84e88
共有 1 個文件被更改,包括 17 次插入 和 6 次删除
  1. 17 6
      services/web/frontend/js/features/plans/group-plan-modal/index.js

+ 17 - 6
services/web/frontend/js/features/plans/group-plan-modal/index.js

@@ -136,14 +136,25 @@ document
     })
     })
   })
   })
 
 
-const isGroupPlanModalAvailable = document.querySelector(
-  '[data-ol-group-plan-modal]'
-)
-
-if (isGroupPlanModalAvailable) {
-  updateGroupModalPlanPricing()
+function updateGroupModalPlanPricingIfAvailable() {
+  const isGroupPlanModalAvailable = document.querySelector(
+    '[data-ol-group-plan-modal]'
+  )
+
+  if (isGroupPlanModalAvailable) {
+    updateGroupModalPlanPricing()
+  }
 }
 }
 
 
+updateGroupModalPlanPricingIfAvailable()
+
+// When using browser back buttons, we need to update the pricing plan
+// after the page has fully loaded as we need to wait for the previously
+// selected values to load for e.g. size.
+window.addEventListener('load', () => {
+  updateGroupModalPlanPricingIfAvailable()
+})
+
 if (window.location.hash === '#groups') {
 if (window.location.hash === '#groups') {
   showGroupPlanModal()
   showGroupPlanModal()
 }
 }