@pushwoosh/dumb-components 1.1.126 → 1.1.129
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { autoPlacement, size, offset, useFloating } from '@floating-ui/react-dom';
|
|
2
2
|
import React, { useState, useEffect } from 'react';
|
|
3
|
-
import { flushSync } from 'react-dom';
|
|
3
|
+
import { createPortal, flushSync } from 'react-dom';
|
|
4
4
|
import { Place } from './styles';
|
|
5
|
-
import { DropdownContext } from '../../context';
|
|
5
|
+
import { DropdownContext, DropdownZIndexContext } from '../../context';
|
|
6
6
|
import { renderChildren } from '../../shared/renderChildren';
|
|
7
7
|
const defaultPlacements = ['top-start', 'top-end', 'bottom-start', 'bottom-end'];
|
|
8
8
|
export const DropdownMenu = ({
|
|
@@ -23,6 +23,7 @@ export const DropdownMenu = ({
|
|
|
23
23
|
refs,
|
|
24
24
|
floatingStyles
|
|
25
25
|
} = useFloating({
|
|
26
|
+
strategy: 'fixed',
|
|
26
27
|
middleware: [size({
|
|
27
28
|
apply({
|
|
28
29
|
rects
|
|
@@ -74,7 +75,9 @@ export const DropdownMenu = ({
|
|
|
74
75
|
},
|
|
75
76
|
ref: refs.setReference,
|
|
76
77
|
isOpen
|
|
77
|
-
}), isOpen && React.createElement(
|
|
78
|
+
}), isOpen && createPortal(React.createElement(DropdownZIndexContext.Provider, {
|
|
79
|
+
value: menuZIndex
|
|
80
|
+
}, React.createElement(Place, {
|
|
78
81
|
ref: refs.setFloating,
|
|
79
82
|
style: floatingStyles,
|
|
80
83
|
"$color": color,
|
|
@@ -82,5 +85,5 @@ export const DropdownMenu = ({
|
|
|
82
85
|
"$fitContent": windowWidth === null && !fullWidth,
|
|
83
86
|
"$scrollable": isScrollable,
|
|
84
87
|
"$zIndex": menuZIndex
|
|
85
|
-
}, renderChildren(children)));
|
|
88
|
+
}, renderChildren(children))), document.body));
|
|
86
89
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { flip, shift, useFloating } from '@floating-ui/react-dom';
|
|
2
2
|
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
3
4
|
import { ChevronIcon } from '@pushwoosh/kit-icons';
|
|
4
5
|
import { SubmenuTriggerInner } from './styles';
|
|
5
|
-
import { DropdownContext } from '../../context';
|
|
6
|
+
import { DropdownContext, DropdownZIndexContext } from '../../context';
|
|
6
7
|
import { renderChildren } from '../../shared/renderChildren';
|
|
7
8
|
import { DropdownMenuItemStyled, Place } from '../../shared/styles';
|
|
8
9
|
const OPEN_DELAY = 100;
|
|
@@ -14,6 +15,8 @@ export const DropdownMenuSubmenu = ({
|
|
|
14
15
|
children
|
|
15
16
|
}) => {
|
|
16
17
|
const parentClose = useContext(DropdownContext);
|
|
18
|
+
const parentZIndex = useContext(DropdownZIndexContext);
|
|
19
|
+
const submenuZIndex = (parentZIndex ?? 10001) + 1;
|
|
17
20
|
const [isOpen, setIsOpen] = useState(false);
|
|
18
21
|
const openedByClick = useRef(false);
|
|
19
22
|
const {
|
|
@@ -57,6 +60,8 @@ export const DropdownMenuSubmenu = ({
|
|
|
57
60
|
}, [parentClose]);
|
|
58
61
|
return React.createElement(DropdownContext.Provider, {
|
|
59
62
|
value: closeChain
|
|
63
|
+
}, React.createElement(DropdownZIndexContext.Provider, {
|
|
64
|
+
value: submenuZIndex
|
|
60
65
|
}, React.createElement(DropdownMenuItemStyled, {
|
|
61
66
|
ref: refs.setReference,
|
|
62
67
|
type: "button",
|
|
@@ -74,12 +79,14 @@ export const DropdownMenuSubmenu = ({
|
|
|
74
79
|
}, React.createElement(SubmenuTriggerInner, null, React.createElement("span", null, label), React.createElement(ChevronIcon, {
|
|
75
80
|
direction: "right",
|
|
76
81
|
size: "small"
|
|
77
|
-
}))), isOpen && React.createElement(Place, {
|
|
82
|
+
}))), isOpen && createPortal(React.createElement(Place, {
|
|
78
83
|
ref: refs.setFloating,
|
|
79
84
|
style: floatingStyles,
|
|
80
85
|
"$width": null,
|
|
81
86
|
"$fitContent": true,
|
|
87
|
+
"$zIndex": submenuZIndex,
|
|
82
88
|
onMouseEnter: clearTimers,
|
|
83
|
-
onMouseLeave: scheduleClose
|
|
84
|
-
|
|
89
|
+
onMouseLeave: scheduleClose,
|
|
90
|
+
onClick: e => e.stopPropagation()
|
|
91
|
+
}, renderChildren(children)), document.body)));
|
|
85
92
|
};
|
package/DropdownMenu/context.js
CHANGED
|
@@ -19,7 +19,7 @@ export const Place = styled(Vertical).withConfig({
|
|
|
19
19
|
$scrollable
|
|
20
20
|
}) => $scrollable && scrollableCss, ShapeRadius.CONTROL, Shadow.REGULAR, ({
|
|
21
21
|
$zIndex
|
|
22
|
-
}) => $zIndex ||
|
|
22
|
+
}) => $zIndex || 10001);
|
|
23
23
|
export const DropdownMenuItemStyled = styled.button.withConfig({
|
|
24
24
|
displayName: "DropdownMenuItemStyled",
|
|
25
25
|
componentId: "sc-hlq2pz-1"
|