@atlaskit/top-layer 1.2.0 → 1.3.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,17 @@
1
1
  # @atlaskit/top-layer
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e297058763bc0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e297058763bc0) -
8
+ Add an `onEnterFinish` lifecycle callback to `Dialog`, and scope its Escape (cancel) handling to
9
+ the dialog the event targets.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 1.2.0
4
16
 
5
17
  ### Minor Changes
package/compass.yml ADDED
@@ -0,0 +1,38 @@
1
+ configVersion: 1
2
+ id: ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:component/c5751cc6-3513-4070-9deb-af31e86aed34/680f1177-ac84-4787-a7d1-258dd657dc9f
3
+ name: '@atlaskit/top-layer'
4
+ ownerId: ari:cloud:identity::team/be19136e-6275-419f-be0c-fcee844b8684 # Design System Engineers
5
+ labels:
6
+ - platform-code
7
+ - platform-afm
8
+ typeId: OTHER
9
+ fields:
10
+ tier: 4
11
+ lifecycle: Active
12
+ isMonorepoProject: true
13
+ links:
14
+ - name: Root Repository
15
+ type: REPOSITORY
16
+ url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master
17
+ - name: Slack Channel
18
+ type: CHAT_CHANNEL
19
+ url: https://atlassian.enterprise.slack.com/archives/CFJ9DU39U # #help-design-system
20
+ - name: Top Layer
21
+ type: REPOSITORY
22
+ url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/design-system/top-layer
23
+ customFields:
24
+ - name: Department
25
+ type: text
26
+ value: Eng - Design System Fundamentals
27
+ - name: Technical Owner
28
+ type: user
29
+ value: ari:cloud:identity::user/557058:86a9b692-7997-49cb-9984-080801b1de91 # Jared Crowe
30
+ - name: Required Reviewers Opt In
31
+ type: boolean
32
+ value: true
33
+ - name: Reviewer Selection Mechanism
34
+ type: text
35
+ value: random(3)
36
+ - name: Required Reviewer Approvals
37
+ type: number
38
+ value: 1
@@ -45,6 +45,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
45
45
  var children = _ref.children,
46
46
  isOpen = _ref.isOpen,
47
47
  onClose = _ref.onClose,
48
+ onEnterFinish = _ref.onEnterFinish,
48
49
  onExitFinish = _ref.onExitFinish,
49
50
  animate = _ref.animate,
50
51
  style = _ref.style,
@@ -61,6 +62,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
61
62
  isOpen: isOpen,
62
63
  animate: animate,
63
64
  elementRef: ownRef,
65
+ onEnterFinish: onEnterFinish,
64
66
  onExitFinish: onExitFinish
65
67
  }),
66
68
  phase = _useAnimatedVisibilit.phase,
@@ -111,6 +113,14 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
111
113
 
112
114
  // Handle native Escape (cancel event)
113
115
  var handleCancel = (0, _react.useCallback)(function (event) {
116
+ // Only handle a cancel targeting THIS dialog. Native `cancel` does not
117
+ // bubble, but React's synthetic event bubbles up the component tree, so
118
+ // for nested dialogs (one rendered inside another's DOM subtree) the
119
+ // inner dialog's Escape would otherwise also fire an ancestor dialog's
120
+ // handler and close it too. Mirrors the backdrop-click target guard below.
121
+ if (event.target !== event.currentTarget) {
122
+ return;
123
+ }
114
124
  event.preventDefault();
115
125
  onClose({
116
126
  reason: 'escape'
@@ -35,6 +35,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
35
35
  children,
36
36
  isOpen,
37
37
  onClose,
38
+ onEnterFinish,
38
39
  onExitFinish,
39
40
  animate,
40
41
  style,
@@ -55,6 +56,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
55
56
  isOpen,
56
57
  animate,
57
58
  elementRef: ownRef,
59
+ onEnterFinish,
58
60
  onExitFinish
59
61
  });
60
62
 
@@ -103,6 +105,14 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
103
105
 
104
106
  // Handle native Escape (cancel event)
105
107
  const handleCancel = useCallback(event => {
108
+ // Only handle a cancel targeting THIS dialog. Native `cancel` does not
109
+ // bubble, but React's synthetic event bubbles up the component tree, so
110
+ // for nested dialogs (one rendered inside another's DOM subtree) the
111
+ // inner dialog's Escape would otherwise also fire an ancestor dialog's
112
+ // handler and close it too. Mirrors the backdrop-click target guard below.
113
+ if (event.target !== event.currentTarget) {
114
+ return;
115
+ }
106
116
  event.preventDefault();
107
117
  onClose({
108
118
  reason: 'escape'
@@ -36,6 +36,7 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
36
36
  var children = _ref.children,
37
37
  isOpen = _ref.isOpen,
38
38
  onClose = _ref.onClose,
39
+ onEnterFinish = _ref.onEnterFinish,
39
40
  onExitFinish = _ref.onExitFinish,
40
41
  animate = _ref.animate,
41
42
  style = _ref.style,
@@ -52,6 +53,7 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
52
53
  isOpen: isOpen,
53
54
  animate: animate,
54
55
  elementRef: ownRef,
56
+ onEnterFinish: onEnterFinish,
55
57
  onExitFinish: onExitFinish
56
58
  }),
57
59
  phase = _useAnimatedVisibilit.phase,
@@ -102,6 +104,14 @@ export var Dialog = /*#__PURE__*/forwardRef(function Dialog(_ref, ref) {
102
104
 
103
105
  // Handle native Escape (cancel event)
104
106
  var handleCancel = useCallback(function (event) {
107
+ // Only handle a cancel targeting THIS dialog. Native `cancel` does not
108
+ // bubble, but React's synthetic event bubbles up the component tree, so
109
+ // for nested dialogs (one rendered inside another's DOM subtree) the
110
+ // inner dialog's Escape would otherwise also fire an ancestor dialog's
111
+ // handler and close it too. Mirrors the backdrop-click target guard below.
112
+ if (event.target !== event.currentTarget) {
113
+ return;
114
+ }
105
115
  event.preventDefault();
106
116
  onClose({
107
117
  reason: 'escape'
@@ -74,6 +74,15 @@ type TDialogBaseProps = {
74
74
  * show a visible backdrop, or when the consumer wants no overlay.
75
75
  */
76
76
  shouldHideBackdrop?: boolean;
77
+ /**
78
+ * Called after the entry animation completes (or immediately on open when
79
+ * there is no animation or reduced motion is active). Also fires on initial
80
+ * mount with `isOpen={true}`.
81
+ *
82
+ * Use this for external lifecycle coordination, e.g. firing an
83
+ * `onOpenComplete` callback once the dialog has finished animating in.
84
+ */
85
+ onEnterFinish?: () => void;
77
86
  /**
78
87
  * Called after the exit animation completes (or immediately on close when
79
88
  * there is no animation or reduced motion is active).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/top-layer",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Low-level layering primitives based on popover and dialog",
5
5
  "homepage": "https://atlassian.design/components/top-layer",
6
6
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/ds-lib": "^8.0.0",
40
40
  "@atlaskit/layering": "^4.1.0",
41
41
  "@atlaskit/react-compiler-gating": "^0.2.0",
42
- "@atlaskit/tokens": "^15.1.0",
42
+ "@atlaskit/tokens": "^15.4.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "@compiled/react": "^0.20.0",
45
45
  "bind-event-listener": "^3.0.0",
@@ -52,10 +52,10 @@
52
52
  "devDependencies": {
53
53
  "@af/integration-testing": "workspace:^",
54
54
  "@af/visual-regression": "workspace:^",
55
- "@atlaskit/button": "^24.2.0",
55
+ "@atlaskit/button": "^24.3.0",
56
56
  "@atlaskit/heading": "^6.1.0",
57
57
  "@atlaskit/lozenge": "^14.1.0",
58
- "@atlaskit/primitives": "^20.1.0",
58
+ "@atlaskit/primitives": "^20.3.0",
59
59
  "@atlaskit/ssr": "workspace:^",
60
60
  "@atlaskit/textfield": "^9.1.0",
61
61
  "@atlassian/ssr-tests": "workspace:^",