@atlaskit/portal 4.9.4 → 4.11.0

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/portal
2
2
 
3
+ ## 4.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#109060](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109060)
8
+ [`4660ec858a305`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4660ec858a305) -
9
+ Update `React` from v16 to v18
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 4.10.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`0e8e931171299`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0e8e931171299) -
20
+ Testing behind a feature gate, adds a Suspense boundary to all created React 18 portals (also
21
+ behind a feature gate)
22
+
3
23
  ## 4.9.4
4
24
 
5
25
  ### Patch Changes
@@ -1,15 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = InternalPortalNew;
8
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _react = require("react");
10
+ var _react = _interopRequireWildcard(require("react"));
10
11
  var _reactDom = require("react-dom");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
13
  var _useIsomorphicLayoutEffect = require("../hooks/use-isomorphic-layout-effect");
12
14
  var _portalDomUtils = require("../utils/portal-dom-utils");
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
17
  function InternalPortalNew(props) {
14
18
  var zIndex = props.zIndex,
15
19
  children = props.children;
@@ -32,5 +36,15 @@ function InternalPortalNew(props) {
32
36
  setAtlaskitPortal(null);
33
37
  };
34
38
  }, [zIndex]);
35
- return atlaskitPortal ? /*#__PURE__*/(0, _reactDom.createPortal)(children, atlaskitPortal) : null;
39
+
40
+ /**
41
+ * Conditionally wrap ALL portal children with Suspense behind a feature gate for safe rollout.
42
+ *
43
+ * This is here because in React 18 concurrent, if you suspend from _within_ a portal to a
44
+ * suspense boundary _outside_ a portal, our portal gets in an infinite loop of re-rendering.
45
+ */
46
+ var conditionallySuspendedChildren = (0, _platformFeatureFlags.fg)('platform_design_system_suspend_portal_children') ? /*#__PURE__*/_react.default.createElement(_react.Suspense, {
47
+ fallback: null
48
+ }, children) : children;
49
+ return atlaskitPortal ? /*#__PURE__*/(0, _reactDom.createPortal)(conditionallySuspendedChildren, atlaskitPortal) : null;
36
50
  }
@@ -1,5 +1,6 @@
1
- import { useState } from 'react';
1
+ import React, { Suspense, useState } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect';
4
5
  import { createAtlaskitPortal, createPortalParent } from '../utils/portal-dom-utils';
5
6
  export default function InternalPortalNew(props) {
@@ -23,5 +24,15 @@ export default function InternalPortalNew(props) {
23
24
  setAtlaskitPortal(null);
24
25
  };
25
26
  }, [zIndex]);
26
- return atlaskitPortal ? /*#__PURE__*/createPortal(children, atlaskitPortal) : null;
27
+
28
+ /**
29
+ * Conditionally wrap ALL portal children with Suspense behind a feature gate for safe rollout.
30
+ *
31
+ * This is here because in React 18 concurrent, if you suspend from _within_ a portal to a
32
+ * suspense boundary _outside_ a portal, our portal gets in an infinite loop of re-rendering.
33
+ */
34
+ const conditionallySuspendedChildren = fg('platform_design_system_suspend_portal_children') ? /*#__PURE__*/React.createElement(Suspense, {
35
+ fallback: null
36
+ }, children) : children;
37
+ return atlaskitPortal ? /*#__PURE__*/createPortal(conditionallySuspendedChildren, atlaskitPortal) : null;
27
38
  }
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { useState } from 'react';
2
+ import React, { Suspense, useState } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect';
5
6
  import { createAtlaskitPortal, createPortalParent } from '../utils/portal-dom-utils';
6
7
  export default function InternalPortalNew(props) {
@@ -25,5 +26,15 @@ export default function InternalPortalNew(props) {
25
26
  setAtlaskitPortal(null);
26
27
  };
27
28
  }, [zIndex]);
28
- return atlaskitPortal ? /*#__PURE__*/createPortal(children, atlaskitPortal) : null;
29
+
30
+ /**
31
+ * Conditionally wrap ALL portal children with Suspense behind a feature gate for safe rollout.
32
+ *
33
+ * This is here because in React 18 concurrent, if you suspend from _within_ a portal to a
34
+ * suspense boundary _outside_ a portal, our portal gets in an infinite loop of re-rendering.
35
+ */
36
+ var conditionallySuspendedChildren = fg('platform_design_system_suspend_portal_children') ? /*#__PURE__*/React.createElement(Suspense, {
37
+ fallback: null
38
+ }, children) : children;
39
+ return atlaskitPortal ? /*#__PURE__*/createPortal(conditionallySuspendedChildren, atlaskitPortal) : null;
29
40
  }
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  interface InternalPortalProps {
3
3
  children: React.ReactNode;
4
4
  zIndex: number | string;
5
5
  }
6
- export default function InternalPortalNew(props: InternalPortalProps): import("react").ReactPortal | null;
6
+ export default function InternalPortalNew(props: InternalPortalProps): React.ReactPortal | null;
7
7
  export {};
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  interface InternalPortalProps {
3
3
  children: React.ReactNode;
4
4
  zIndex: number | string;
5
5
  }
6
- export default function InternalPortalNew(props: InternalPortalProps): import("react").ReactPortal | null;
6
+ export default function InternalPortalNew(props: InternalPortalProps): React.ReactPortal | null;
7
7
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/portal",
3
- "version": "4.9.4",
3
+ "version": "4.11.0",
4
4
  "description": "A wrapper for rendering components in React portals.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@atlaskit/platform-feature-flags": "^0.3.0",
41
- "@atlaskit/theme": "^14.0.0",
41
+ "@atlaskit/theme": "^14.1.0",
42
42
  "@babel/runtime": "^7.0.0"
43
43
  },
44
44
  "peerDependencies": {
@@ -48,15 +48,15 @@
48
48
  "devDependencies": {
49
49
  "@af/accessibility-testing": "*",
50
50
  "@af/integration-testing": "*",
51
- "@atlaskit/ds-lib": "^3.2.0",
52
- "@atlaskit/modal-dialog": "^12.17.0",
51
+ "@atlaskit/ds-lib": "^3.5.0",
52
+ "@atlaskit/modal-dialog": "^12.20.0",
53
53
  "@atlaskit/ssr": "*",
54
- "@atlaskit/tokens": "^2.2.0",
55
- "@atlaskit/tooltip": "^18.9.0",
54
+ "@atlaskit/tokens": "^3.3.0",
55
+ "@atlaskit/tooltip": "^19.1.0",
56
56
  "@atlaskit/visual-regression": "*",
57
- "@atlassian/feature-flags-test-utils": "^0.2.0",
57
+ "@atlassian/feature-flags-test-utils": "^0.3.0",
58
58
  "@emotion/react": "^11.7.1",
59
- "@testing-library/react": "^12.1.5",
59
+ "@testing-library/react": "^13.4.0",
60
60
  "@testing-library/react-hooks": "^8.0.1",
61
61
  "bind-event-listener": "^3.0.0",
62
62
  "raf-stub": "^2.0.1",
@@ -92,6 +92,9 @@
92
92
  "platform-feature-flags": {
93
93
  "platform_design_system_team_portal_logic_r18_fix": {
94
94
  "type": "boolean"
95
+ },
96
+ "platform_design_system_suspend_portal_children": {
97
+ "type": "boolean"
95
98
  }
96
99
  }
97
100
  }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
-
3
- import Portal from '../src';
4
-
5
- export default () => (
6
- <Portal zIndex={100}>
7
- <p>portal</p>
8
- </Portal>
9
- );
@@ -1,36 +0,0 @@
1
- import React from 'react';
2
-
3
- import { token } from '@atlaskit/tokens';
4
-
5
- import Portal from '../src';
6
-
7
- const PortalPerformance = () => {
8
- return (
9
- <Portal zIndex={200}>
10
- <div
11
- style={{
12
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
13
- position: 'absolute',
14
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
15
- top: token('space.300', '24px'),
16
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
17
- left: token('space.300', '24px'),
18
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
19
- background: 'lightpink',
20
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
21
- padding: token('space.300', '24px'),
22
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
23
- borderRadius: '3px',
24
- // this z-index is relative to the portal
25
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
26
- zIndex: 1,
27
- }}
28
- >
29
- <p>portal z-index: 200</p>
30
- <p>element z-index: 1</p>
31
- </div>
32
- </Portal>
33
- );
34
- };
35
-
36
- export default PortalPerformance;