@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/dist/ui.esm.js
CHANGED
|
@@ -1738,16 +1738,22 @@ const DropdownItem = /*#__PURE__*/forwardRef(function Button({
|
|
|
1738
1738
|
*/
|
|
1739
1739
|
|
|
1740
1740
|
const useDropdownPosition = () => {
|
|
1741
|
-
var _dropdownButtonRef$cu, _buttonRect$top, _buttonRect$height, _buttonRect$left;
|
|
1741
|
+
var _dropdownButtonRef$cu, _buttonRect$top, _buttonRect$height, _buttonRect$left, _document, _document$documentEle, _document2, _document2$documentEl;
|
|
1742
1742
|
|
|
1743
1743
|
const {
|
|
1744
1744
|
dropdownButtonRef
|
|
1745
|
-
} = useDropdown();
|
|
1745
|
+
} = useDropdown(); // Necessary to use this component in SSR
|
|
1746
|
+
|
|
1747
|
+
const isBrowser = typeof window !== 'undefined';
|
|
1746
1748
|
const buttonRect = dropdownButtonRef == null ? void 0 : (_dropdownButtonRef$cu = dropdownButtonRef.current) == null ? void 0 : _dropdownButtonRef$cu.getBoundingClientRect();
|
|
1747
1749
|
const topLevel = (_buttonRect$top = buttonRect == null ? void 0 : buttonRect.top) != null ? _buttonRect$top : 0;
|
|
1748
1750
|
const topOffset = (_buttonRect$height = buttonRect == null ? void 0 : buttonRect.height) != null ? _buttonRect$height : 0;
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
+
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.
|
|
1752
|
+
|
|
1753
|
+
const scrollTop = isBrowser ? (_document = document) == null ? void 0 : (_document$documentEle = _document.documentElement) == null ? void 0 : _document$documentEle.scrollTop : 0;
|
|
1754
|
+
const scrollLeft = isBrowser ? (_document2 = document) == null ? void 0 : (_document2$documentEl = _document2.documentElement) == null ? void 0 : _document2$documentEl.scrollLeft : 0;
|
|
1755
|
+
const topPosition = topLevel + topOffset + scrollTop;
|
|
1756
|
+
const leftPosition = leftLevel + scrollLeft;
|
|
1751
1757
|
return {
|
|
1752
1758
|
position: 'absolute',
|
|
1753
1759
|
top: topPosition,
|
|
@@ -1820,16 +1826,16 @@ const DropdownMenu = ({
|
|
|
1820
1826
|
};
|
|
1821
1827
|
|
|
1822
1828
|
const handleBackdropKeyDown = event => {
|
|
1823
|
-
if (event.defaultPrevented) {
|
|
1829
|
+
if (event.defaultPrevented || event.key === 'Enter') {
|
|
1824
1830
|
return;
|
|
1825
1831
|
}
|
|
1826
1832
|
|
|
1833
|
+
event.preventDefault();
|
|
1827
1834
|
event.key === 'Escape' && handleEscapePress();
|
|
1828
1835
|
event.key === 'ArrowDown' && handleDownPress();
|
|
1829
1836
|
event.key === 'ArrowUp' && handleUpPress();
|
|
1830
1837
|
event.key === 'Home' && handleHomePress();
|
|
1831
1838
|
event.key === 'End' && handleEndPress();
|
|
1832
|
-
event.key === 'Tab' && event.preventDefault();
|
|
1833
1839
|
event.stopPropagation();
|
|
1834
1840
|
};
|
|
1835
1841
|
|