@atlaskit/popup 1.30.2 → 1.30.3

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,13 @@
1
1
  # @atlaskit/popup
2
2
 
3
+ ## 1.30.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#181817](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/181817)
8
+ [`6876e5688ed14`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6876e5688ed14) -
9
+ Dropdown open in iframe should be closed when clicking outside of the iframe
10
+
3
11
  ## 1.30.2
4
12
 
5
13
  ### Patch Changes
@@ -34,6 +34,7 @@ var useCloseManager = exports.useCloseManager = function useCloseManager(_ref) {
34
34
  if (!isOpen || !popupRef) {
35
35
  return _noop.default;
36
36
  }
37
+ var inIframe = window && window.self !== window.top && (0, _platformFeatureFlags.fg)('fix-dropdown-close-outside-iframe');
37
38
  var closePopup = function closePopup(event) {
38
39
  if (onClose) {
39
40
  if ((0, _platformFeatureFlags.fg)('sibling-dropdown-close-issue')) {
@@ -68,7 +69,7 @@ var useCloseManager = exports.useCloseManager = function useCloseManager(_ref) {
68
69
  var onClick = function onClick(event) {
69
70
  var target = event.target;
70
71
  var doesDomNodeExist = document.body.contains(target);
71
- if (!doesDomNodeExist) {
72
+ if (!doesDomNodeExist && !inIframe) {
72
73
  return;
73
74
  }
74
75
  if (isLayerDisabled()) {
@@ -175,6 +176,18 @@ var useCloseManager = exports.useCloseManager = function useCloseManager(_ref) {
175
176
  }
176
177
  }
177
178
  };
179
+ var parentUnbind;
180
+ // if the popup is inside iframe, we want to listen to click events outside iframe,
181
+ // to close the popup correctly in the iframe.
182
+ if (inIframe && isOpen) {
183
+ parentUnbind = (0, _bindEventListener.bind)(window.parent.window, {
184
+ type: 'click',
185
+ listener: onClick,
186
+ options: {
187
+ capture: capture
188
+ }
189
+ });
190
+ }
178
191
  var unbind = (0, _bindEventListener.bindAll)(window, [{
179
192
  type: 'click',
180
193
  listener: onClick,
@@ -198,8 +211,10 @@ var useCloseManager = exports.useCloseManager = function useCloseManager(_ref) {
198
211
  }
199
212
  });
200
213
  return function () {
214
+ var _parentUnbind;
201
215
  cancelAllFrames();
202
216
  unbind();
217
+ (_parentUnbind = parentUnbind) === null || _parentUnbind === void 0 || _parentUnbind();
203
218
  unbindBlur();
204
219
  };
205
220
  }, [isOpen, onClose, popupRef, triggerRef, autoFocus, shouldDisableFocusTrap, capture, isLayerDisabled, shouldCloseOnTab, currentLevel, shouldRenderToParent, requestFrame, cancelAllFrames]);
@@ -29,6 +29,7 @@ export const useCloseManager = ({
29
29
  if (!isOpen || !popupRef) {
30
30
  return noop;
31
31
  }
32
+ const inIframe = window && window.self !== window.top && fg('fix-dropdown-close-outside-iframe');
32
33
  const closePopup = event => {
33
34
  if (onClose) {
34
35
  if (fg('sibling-dropdown-close-issue')) {
@@ -65,7 +66,7 @@ export const useCloseManager = ({
65
66
  target
66
67
  } = event;
67
68
  const doesDomNodeExist = document.body.contains(target);
68
- if (!doesDomNodeExist) {
69
+ if (!doesDomNodeExist && !inIframe) {
69
70
  return;
70
71
  }
71
72
  if (isLayerDisabled()) {
@@ -176,6 +177,18 @@ export const useCloseManager = ({
176
177
  }
177
178
  }
178
179
  };
180
+ let parentUnbind;
181
+ // if the popup is inside iframe, we want to listen to click events outside iframe,
182
+ // to close the popup correctly in the iframe.
183
+ if (inIframe && isOpen) {
184
+ parentUnbind = bind(window.parent.window, {
185
+ type: 'click',
186
+ listener: onClick,
187
+ options: {
188
+ capture
189
+ }
190
+ });
191
+ }
179
192
  const unbind = bindAll(window, [{
180
193
  type: 'click',
181
194
  listener: onClick,
@@ -199,8 +212,10 @@ export const useCloseManager = ({
199
212
  }
200
213
  });
201
214
  return () => {
215
+ var _parentUnbind;
202
216
  cancelAllFrames();
203
217
  unbind();
218
+ (_parentUnbind = parentUnbind) === null || _parentUnbind === void 0 ? void 0 : _parentUnbind();
204
219
  unbindBlur();
205
220
  };
206
221
  }, [isOpen, onClose, popupRef, triggerRef, autoFocus, shouldDisableFocusTrap, capture, isLayerDisabled, shouldCloseOnTab, currentLevel, shouldRenderToParent, requestFrame, cancelAllFrames]);
@@ -26,6 +26,7 @@ export var useCloseManager = function useCloseManager(_ref) {
26
26
  if (!isOpen || !popupRef) {
27
27
  return noop;
28
28
  }
29
+ var inIframe = window && window.self !== window.top && fg('fix-dropdown-close-outside-iframe');
29
30
  var closePopup = function closePopup(event) {
30
31
  if (onClose) {
31
32
  if (fg('sibling-dropdown-close-issue')) {
@@ -60,7 +61,7 @@ export var useCloseManager = function useCloseManager(_ref) {
60
61
  var onClick = function onClick(event) {
61
62
  var target = event.target;
62
63
  var doesDomNodeExist = document.body.contains(target);
63
- if (!doesDomNodeExist) {
64
+ if (!doesDomNodeExist && !inIframe) {
64
65
  return;
65
66
  }
66
67
  if (isLayerDisabled()) {
@@ -167,6 +168,18 @@ export var useCloseManager = function useCloseManager(_ref) {
167
168
  }
168
169
  }
169
170
  };
171
+ var parentUnbind;
172
+ // if the popup is inside iframe, we want to listen to click events outside iframe,
173
+ // to close the popup correctly in the iframe.
174
+ if (inIframe && isOpen) {
175
+ parentUnbind = bind(window.parent.window, {
176
+ type: 'click',
177
+ listener: onClick,
178
+ options: {
179
+ capture: capture
180
+ }
181
+ });
182
+ }
170
183
  var unbind = bindAll(window, [{
171
184
  type: 'click',
172
185
  listener: onClick,
@@ -190,8 +203,10 @@ export var useCloseManager = function useCloseManager(_ref) {
190
203
  }
191
204
  });
192
205
  return function () {
206
+ var _parentUnbind;
193
207
  cancelAllFrames();
194
208
  unbind();
209
+ (_parentUnbind = parentUnbind) === null || _parentUnbind === void 0 || _parentUnbind();
195
210
  unbindBlur();
196
211
  };
197
212
  }, [isOpen, onClose, popupRef, triggerRef, autoFocus, shouldDisableFocusTrap, capture, isLayerDisabled, shouldCloseOnTab, currentLevel, shouldRenderToParent, requestFrame, cancelAllFrames]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.30.2",
3
+ "version": "1.30.3",
4
4
  "description": "A popup displays brief content in an overlay.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -123,6 +123,9 @@
123
123
  },
124
124
  "platform-design-system-apply-popup-wrapper-focus": {
125
125
  "type": "boolean"
126
+ },
127
+ "fix-dropdown-close-outside-iframe": {
128
+ "type": "boolean"
126
129
  }
127
130
  },
128
131
  "homepage": "https://atlassian.design/components/popup/"