@dhis2-ui/portal 8.14.4 → 8.14.6
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/build/cjs/portal.js +4 -2
- package/build/es/portal.js +5 -2
- package/package.json +1 -1
package/build/cjs/portal.js
CHANGED
|
@@ -21,8 +21,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
21
|
* template.
|
|
22
22
|
*
|
|
23
23
|
* As a fallback, portals will be attached to the document body.
|
|
24
|
+
*
|
|
25
|
+
* This needs to be a function so that it works in tests as well.
|
|
24
26
|
*/
|
|
25
|
-
const
|
|
27
|
+
const getDefaultNode = () => document.getElementById('dhis2-portal-root') || document.body;
|
|
26
28
|
|
|
27
29
|
const Portal = _ref => {
|
|
28
30
|
let {
|
|
@@ -32,7 +34,7 @@ const Portal = _ref => {
|
|
|
32
34
|
} = _ref;
|
|
33
35
|
const [mountNode, setMountNode] = (0, _react.useState)(null);
|
|
34
36
|
(0, _react.useEffect)(() => {
|
|
35
|
-
setMountNode(node ||
|
|
37
|
+
setMountNode(node || getDefaultNode());
|
|
36
38
|
}, [node]);
|
|
37
39
|
|
|
38
40
|
if (disable) {
|
package/build/es/portal.js
CHANGED
|
@@ -9,9 +9,12 @@ import { createPortal } from 'react-dom';
|
|
|
9
9
|
* template.
|
|
10
10
|
*
|
|
11
11
|
* As a fallback, portals will be attached to the document body.
|
|
12
|
+
*
|
|
13
|
+
* This needs to be a function so that it works in tests as well.
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
|
-
const
|
|
16
|
+
const getDefaultNode = () => document.getElementById('dhis2-portal-root') || document.body;
|
|
17
|
+
|
|
15
18
|
export const Portal = _ref => {
|
|
16
19
|
let {
|
|
17
20
|
children,
|
|
@@ -20,7 +23,7 @@ export const Portal = _ref => {
|
|
|
20
23
|
} = _ref;
|
|
21
24
|
const [mountNode, setMountNode] = useState(null);
|
|
22
25
|
useEffect(() => {
|
|
23
|
-
setMountNode(node ||
|
|
26
|
+
setMountNode(node || getDefaultNode());
|
|
24
27
|
}, [node]);
|
|
25
28
|
|
|
26
29
|
if (disable) {
|