@faststore/ui 1.6.26 → 1.6.29
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/CHANGELOG.md +30 -0
- package/dist/molecules/Dropdown/hooks/useDropdownPosition.d.ts +2 -5
- package/dist/ui.cjs.development.js +12 -6
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +12 -6
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/molecules/Dropdown/Dropdown.test.tsx +10 -5
- package/src/molecules/Dropdown/DropdownMenu.tsx +3 -3
- package/src/molecules/Dropdown/hooks/useDropdownPosition.ts +16 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 1.6.29 (2022-03-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fix dropdown render in SSR ([#1202](https://github.com/vtex/faststore/issues/1202)) ([60f65b0](https://github.com/vtex/faststore/commit/60f65b0864c2fb59dff61e914c69a326b5229984))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 1.6.28 (2022-03-31)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* fix dropdown menu position with scroll ([#1199](https://github.com/vtex/faststore/issues/1199)) ([98a228e](https://github.com/vtex/faststore/commit/98a228e364ed26e480936406c1988026f9ebaffc))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## 1.6.27 (2022-03-31)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @faststore/ui
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
## 1.6.26 (2022-03-31)
|
|
7
37
|
|
|
8
38
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
top: number;
|
|
4
|
-
left: number;
|
|
5
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type DropdownPosition = Pick<React.CSSProperties, 'position' | 'top' | 'left'>;
|
|
6
3
|
/**
|
|
7
4
|
* Hook used to find the DropdownMenu position in relation to DropdownButton
|
|
8
5
|
* @returns Style with positions.
|
|
@@ -1746,16 +1746,22 @@ const DropdownItem = /*#__PURE__*/React.forwardRef(function Button({
|
|
|
1746
1746
|
*/
|
|
1747
1747
|
|
|
1748
1748
|
const useDropdownPosition = () => {
|
|
1749
|
-
var _dropdownButtonRef$cu, _buttonRect$top, _buttonRect$height, _buttonRect$left;
|
|
1749
|
+
var _dropdownButtonRef$cu, _buttonRect$top, _buttonRect$height, _buttonRect$left, _document, _document$documentEle, _document2, _document2$documentEl;
|
|
1750
1750
|
|
|
1751
1751
|
const {
|
|
1752
1752
|
dropdownButtonRef
|
|
1753
|
-
} = useDropdown();
|
|
1753
|
+
} = useDropdown(); // Necessary to use this component in SSR
|
|
1754
|
+
|
|
1755
|
+
const isBrowser = typeof window !== 'undefined';
|
|
1754
1756
|
const buttonRect = dropdownButtonRef == null ? void 0 : (_dropdownButtonRef$cu = dropdownButtonRef.current) == null ? void 0 : _dropdownButtonRef$cu.getBoundingClientRect();
|
|
1755
1757
|
const topLevel = (_buttonRect$top = buttonRect == null ? void 0 : buttonRect.top) != null ? _buttonRect$top : 0;
|
|
1756
1758
|
const topOffset = (_buttonRect$height = buttonRect == null ? void 0 : buttonRect.height) != null ? _buttonRect$height : 0;
|
|
1757
|
-
const
|
|
1758
|
-
|
|
1759
|
+
const leftLevel = (_buttonRect$left = buttonRect == null ? void 0 : buttonRect.left) != null ? _buttonRect$left : 0; // The scroll properties fix the position of DropdownMenu when the scroll is activated.
|
|
1760
|
+
|
|
1761
|
+
const scrollTop = isBrowser ? (_document = document) == null ? void 0 : (_document$documentEle = _document.documentElement) == null ? void 0 : _document$documentEle.scrollTop : 0;
|
|
1762
|
+
const scrollLeft = isBrowser ? (_document2 = document) == null ? void 0 : (_document2$documentEl = _document2.documentElement) == null ? void 0 : _document2$documentEl.scrollLeft : 0;
|
|
1763
|
+
const topPosition = topLevel + topOffset + scrollTop;
|
|
1764
|
+
const leftPosition = leftLevel + scrollLeft;
|
|
1759
1765
|
return {
|
|
1760
1766
|
position: 'absolute',
|
|
1761
1767
|
top: topPosition,
|
|
@@ -1828,16 +1834,16 @@ const DropdownMenu = ({
|
|
|
1828
1834
|
};
|
|
1829
1835
|
|
|
1830
1836
|
const handleBackdropKeyDown = event => {
|
|
1831
|
-
if (event.defaultPrevented) {
|
|
1837
|
+
if (event.defaultPrevented || event.key === 'Enter') {
|
|
1832
1838
|
return;
|
|
1833
1839
|
}
|
|
1834
1840
|
|
|
1841
|
+
event.preventDefault();
|
|
1835
1842
|
event.key === 'Escape' && handleEscapePress();
|
|
1836
1843
|
event.key === 'ArrowDown' && handleDownPress();
|
|
1837
1844
|
event.key === 'ArrowUp' && handleUpPress();
|
|
1838
1845
|
event.key === 'Home' && handleHomePress();
|
|
1839
1846
|
event.key === 'End' && handleEndPress();
|
|
1840
|
-
event.key === 'Tab' && event.preventDefault();
|
|
1841
1847
|
event.stopPropagation();
|
|
1842
1848
|
};
|
|
1843
1849
|
|