ublo-lib 1.14.3 → 1.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,13 +23,19 @@ export default function useSeasonProducts(menuPath) {
23
23
  window.sessionStorage.setItem("stay", stay);
24
24
  window.sessionStorage.setItem(STORAGE_KEY, true);
25
25
  }, [endDate, startDate]);
26
+ const handleButtonClick = React.useCallback(e => {
27
+ const button = e.target.closest("[onclick*='openBoutiqueESF']");
28
+ if (!button) return;
29
+ e.preventDefault();
30
+ updateStay();
31
+ button.click();
32
+ }, [updateStay]);
26
33
  React.useEffect(() => {
27
34
  if (isEnabled) {
28
35
  if (seasonProductsPage) {
29
- const buttons = Array.from(document.querySelectorAll("[onclick*='openBoutiqueESF']"));
30
- buttons.forEach(button => button.addEventListener("click", updateStay));
36
+ document.addEventListener("click", handleButtonClick);
31
37
  return () => {
32
- buttons.forEach(button => button.removeEventListener("click", updateStay));
38
+ document.removeEventListener("click", handleButtonClick);
33
39
  };
34
40
  } else {
35
41
  const hasForcedStay = window.sessionStorage.getItem(STORAGE_KEY);
@@ -40,7 +46,7 @@ export default function useSeasonProducts(menuPath) {
40
46
  }
41
47
  }
42
48
  }
43
- }, [isEnabled, seasonProductsPage, updateStay]);
49
+ }, [handleButtonClick, isEnabled, seasonProductsPage]);
44
50
  }
45
51
  function padStart(value, count, pad) {
46
52
  let str = String(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.14.3",
3
+ "version": "1.14.4",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^2.1.0",
6
6
  "leaflet": "^1.9.1",