@faststore/ui 1.6.28 → 1.7.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/ui",
3
- "version": "1.6.28",
3
+ "version": "1.7.2",
4
4
  "description": "A lightweight, framework agnostic component library for React",
5
5
  "author": "emersonlaurentino",
6
6
  "license": "MIT",
@@ -76,7 +76,7 @@
76
76
  "@types/jest-axe": "^3.5.3",
77
77
  "@types/tabbable": "^3.1.1",
78
78
  "@types/testing-library__jest-dom": "^5.9.5",
79
- "@vtex/theme-b2c-tailwind": "^1.6.28",
79
+ "@vtex/theme-b2c-tailwind": "^1.7.2",
80
80
  "@vtex/tsconfig": "^0.5.0",
81
81
  "chalk": "^5.0.0",
82
82
  "jest-axe": "^5.0.1",
@@ -89,5 +89,5 @@
89
89
  "tsdx": "^0.14.1",
90
90
  "typescript": "^4.2.4"
91
91
  },
92
- "gitHead": "186871fcbc4692604f7ec66317d13ce1182f2937"
92
+ "gitHead": "3b1a2eaf40c4f4eb21787b9e34c7cad67f42e1de"
93
93
  }
@@ -9,14 +9,21 @@ type DropdownPosition = Pick<React.CSSProperties, 'position' | 'top' | 'left'>
9
9
  export const useDropdownPosition = (): DropdownPosition => {
10
10
  const { dropdownButtonRef } = useDropdown()
11
11
 
12
+ // Necessary to use this component in SSR
13
+ const isBrowser = typeof window !== 'undefined'
14
+
12
15
  const buttonRect = dropdownButtonRef?.current?.getBoundingClientRect()
13
- const topLevel: number = buttonRect?.top ?? 0
14
- const topOffset: number = buttonRect?.height ?? 0
16
+ const topLevel = buttonRect?.top ?? 0
17
+ const topOffset = buttonRect?.height ?? 0
18
+ const leftLevel = buttonRect?.left ?? 0
15
19
 
16
20
  // The scroll properties fix the position of DropdownMenu when the scroll is activated.
17
- const topPosition = topLevel + topOffset + document.documentElement.scrollTop
18
- const leftLevel = buttonRect?.left ?? 0
19
- const leftPosition = leftLevel + document.documentElement.scrollLeft
21
+ const scrollTop = isBrowser ? document?.documentElement?.scrollTop : 0
22
+ const scrollLeft = isBrowser ? document?.documentElement?.scrollLeft : 0
23
+
24
+ const topPosition = topLevel + topOffset + scrollTop
25
+
26
+ const leftPosition = leftLevel + scrollLeft
20
27
 
21
28
  return {
22
29
  position: 'absolute',