@diwauhris/ui 1.7.37 → 1.7.38
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/lib/index.cjs +18 -8
- package/lib/index.mjs +18 -8
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -3994,14 +3994,24 @@ function Dropdown({ trigger, isOpen, onToggle, onClose, children, triggerClassNa
|
|
|
3994
3994
|
const [panelStyle, setPanelStyle] = (0, react.useState)({});
|
|
3995
3995
|
(0, react.useEffect)(() => {
|
|
3996
3996
|
if (!isOpen || !triggerRef.current) return;
|
|
3997
|
-
const
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
3997
|
+
const updatePosition = () => {
|
|
3998
|
+
if (!triggerRef.current) return;
|
|
3999
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
4000
|
+
setPanelStyle({
|
|
4001
|
+
position: "fixed",
|
|
4002
|
+
top: rect.bottom + 4,
|
|
4003
|
+
left: rect.left,
|
|
4004
|
+
zIndex: 9999,
|
|
4005
|
+
minWidth: Math.max(rect.width, 180)
|
|
4006
|
+
});
|
|
4007
|
+
};
|
|
4008
|
+
updatePosition();
|
|
4009
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
4010
|
+
window.addEventListener("resize", updatePosition);
|
|
4011
|
+
return () => {
|
|
4012
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
4013
|
+
window.removeEventListener("resize", updatePosition);
|
|
4014
|
+
};
|
|
4005
4015
|
}, [isOpen]);
|
|
4006
4016
|
(0, react.useEffect)(() => {
|
|
4007
4017
|
if (!isOpen) return;
|
package/lib/index.mjs
CHANGED
|
@@ -3970,14 +3970,24 @@ function Dropdown({ trigger, isOpen, onToggle, onClose, children, triggerClassNa
|
|
|
3970
3970
|
const [panelStyle, setPanelStyle] = useState({});
|
|
3971
3971
|
useEffect(() => {
|
|
3972
3972
|
if (!isOpen || !triggerRef.current) return;
|
|
3973
|
-
const
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3973
|
+
const updatePosition = () => {
|
|
3974
|
+
if (!triggerRef.current) return;
|
|
3975
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
3976
|
+
setPanelStyle({
|
|
3977
|
+
position: "fixed",
|
|
3978
|
+
top: rect.bottom + 4,
|
|
3979
|
+
left: rect.left,
|
|
3980
|
+
zIndex: 9999,
|
|
3981
|
+
minWidth: Math.max(rect.width, 180)
|
|
3982
|
+
});
|
|
3983
|
+
};
|
|
3984
|
+
updatePosition();
|
|
3985
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
3986
|
+
window.addEventListener("resize", updatePosition);
|
|
3987
|
+
return () => {
|
|
3988
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
3989
|
+
window.removeEventListener("resize", updatePosition);
|
|
3990
|
+
};
|
|
3981
3991
|
}, [isOpen]);
|
|
3982
3992
|
useEffect(() => {
|
|
3983
3993
|
if (!isOpen) return;
|