@atlaskit/tooltip 20.0.4 → 20.0.5

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,14 @@
1
1
  # @atlaskit/tooltip
2
2
 
3
+ ## 20.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#134955](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134955)
8
+ [`ba294ad0536de`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ba294ad0536de) -
9
+ An onClose listener is being provided to the experimental open layer observer.
10
+ - Updated dependencies
11
+
3
12
  ## 20.0.4
4
13
 
5
14
  ### Patch Changes
@@ -17,6 +17,7 @@ var _useCloseOnEscapePress = _interopRequireDefault(require("@atlaskit/ds-lib/us
17
17
  var _useStableRef = _interopRequireDefault(require("@atlaskit/ds-lib/use-stable-ref"));
18
18
  var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
19
19
  var _motion = require("@atlaskit/motion");
20
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
21
  var _popper = require("@atlaskit/popper");
21
22
  var _portal = _interopRequireDefault(require("@atlaskit/portal"));
22
23
  var _constants = require("@atlaskit/theme/constants");
@@ -33,7 +34,7 @@ var tooltipZIndex = _constants.layers.tooltip();
33
34
  var analyticsAttributes = {
34
35
  componentName: 'tooltip',
35
36
  packageName: "@atlaskit/tooltip",
36
- packageVersion: "20.0.4"
37
+ packageVersion: "20.0.5"
37
38
  };
38
39
 
39
40
  // Inverts motion direction
@@ -400,14 +401,30 @@ function Tooltip(_ref) {
400
401
  var shouldRenderTooltipPopup = state !== 'hide' && Boolean(content);
401
402
  var shouldRenderHiddenContent = !isScreenReaderAnnouncementDisabled && shouldRenderTooltipPopup;
402
403
  var shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
404
+ var handleOpenLayerObserverCloseSignal = (0, _react.useCallback)(function () {
405
+ var _apiRef$current4;
406
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.requestHide({
407
+ isImmediate: true
408
+ });
409
+ }, []);
403
410
  (0, _openLayerObserver.useNotifyOpenLayerObserver)({
404
- isOpen: shouldRenderTooltipPopup
411
+ // Layer is only visually open if both the tooltip popup (container) and children are rendered.
412
+ isOpen: shouldRenderTooltipPopup && ((0, _platformFeatureFlags.fg)('platform_dst_open_layer_observer_close_layers') ? shouldRenderTooltipChildren : true),
413
+ /**
414
+ * We don't strictly need to provide an onClose callback at this time, as there is
415
+ * already code that handles hiding the tooltip when a drag is started (and the only
416
+ * usage right now is closing all layers when the user resizes the side nav).
417
+ *
418
+ * However, for future-proofing and semantic reasons, it makes sense to close the tooltip
419
+ * whenever the open layer observer requests a close.
420
+ */
421
+ onClose: handleOpenLayerObserverCloseSignal
405
422
  });
406
423
  var getReferenceElement = function getReferenceElement() {
407
- var _apiRef$current4;
408
- if (position === 'mouse' && (_apiRef$current4 = apiRef.current) !== null && _apiRef$current4 !== void 0 && _apiRef$current4.mousePosition) {
409
- var _apiRef$current5;
410
- return (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : _apiRef$current5.mousePosition;
424
+ var _apiRef$current5;
425
+ if (position === 'mouse' && (_apiRef$current5 = apiRef.current) !== null && _apiRef$current5 !== void 0 && _apiRef$current5.mousePosition) {
426
+ var _apiRef$current6;
427
+ return (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.mousePosition;
411
428
  }
412
429
  return targetRef.current || undefined;
413
430
  };
@@ -7,6 +7,7 @@ import useCloseOnEscapePress from '@atlaskit/ds-lib/use-close-on-escape-press';
7
7
  import useStableRef from '@atlaskit/ds-lib/use-stable-ref';
8
8
  import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
9
9
  import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { Popper } from '@atlaskit/popper';
11
12
  import Portal from '@atlaskit/portal';
12
13
  import { layers } from '@atlaskit/theme/constants';
@@ -19,7 +20,7 @@ const tooltipZIndex = layers.tooltip();
19
20
  const analyticsAttributes = {
20
21
  componentName: 'tooltip',
21
22
  packageName: "@atlaskit/tooltip",
22
- packageVersion: "20.0.4"
23
+ packageVersion: "20.0.5"
23
24
  };
24
25
 
25
26
  // Inverts motion direction
@@ -375,14 +376,30 @@ function Tooltip({
375
376
  const shouldRenderTooltipPopup = state !== 'hide' && Boolean(content);
376
377
  const shouldRenderHiddenContent = !isScreenReaderAnnouncementDisabled && shouldRenderTooltipPopup;
377
378
  const shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
379
+ const handleOpenLayerObserverCloseSignal = useCallback(() => {
380
+ var _apiRef$current4;
381
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 ? void 0 : _apiRef$current4.requestHide({
382
+ isImmediate: true
383
+ });
384
+ }, []);
378
385
  useNotifyOpenLayerObserver({
379
- isOpen: shouldRenderTooltipPopup
386
+ // Layer is only visually open if both the tooltip popup (container) and children are rendered.
387
+ isOpen: shouldRenderTooltipPopup && (fg('platform_dst_open_layer_observer_close_layers') ? shouldRenderTooltipChildren : true),
388
+ /**
389
+ * We don't strictly need to provide an onClose callback at this time, as there is
390
+ * already code that handles hiding the tooltip when a drag is started (and the only
391
+ * usage right now is closing all layers when the user resizes the side nav).
392
+ *
393
+ * However, for future-proofing and semantic reasons, it makes sense to close the tooltip
394
+ * whenever the open layer observer requests a close.
395
+ */
396
+ onClose: handleOpenLayerObserverCloseSignal
380
397
  });
381
398
  const getReferenceElement = () => {
382
- var _apiRef$current4;
383
- if (position === 'mouse' && (_apiRef$current4 = apiRef.current) !== null && _apiRef$current4 !== void 0 && _apiRef$current4.mousePosition) {
384
- var _apiRef$current5;
385
- return (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : _apiRef$current5.mousePosition;
399
+ var _apiRef$current5;
400
+ if (position === 'mouse' && (_apiRef$current5 = apiRef.current) !== null && _apiRef$current5 !== void 0 && _apiRef$current5.mousePosition) {
401
+ var _apiRef$current6;
402
+ return (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.mousePosition;
386
403
  }
387
404
  return targetRef.current || undefined;
388
405
  };
@@ -11,6 +11,7 @@ import useCloseOnEscapePress from '@atlaskit/ds-lib/use-close-on-escape-press';
11
11
  import useStableRef from '@atlaskit/ds-lib/use-stable-ref';
12
12
  import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
13
13
  import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
14
+ import { fg } from '@atlaskit/platform-feature-flags';
14
15
  import { Popper } from '@atlaskit/popper';
15
16
  import Portal from '@atlaskit/portal';
16
17
  import { layers } from '@atlaskit/theme/constants';
@@ -23,7 +24,7 @@ var tooltipZIndex = layers.tooltip();
23
24
  var analyticsAttributes = {
24
25
  componentName: 'tooltip',
25
26
  packageName: "@atlaskit/tooltip",
26
- packageVersion: "20.0.4"
27
+ packageVersion: "20.0.5"
27
28
  };
28
29
 
29
30
  // Inverts motion direction
@@ -390,14 +391,30 @@ function Tooltip(_ref) {
390
391
  var shouldRenderTooltipPopup = state !== 'hide' && Boolean(content);
391
392
  var shouldRenderHiddenContent = !isScreenReaderAnnouncementDisabled && shouldRenderTooltipPopup;
392
393
  var shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
394
+ var handleOpenLayerObserverCloseSignal = useCallback(function () {
395
+ var _apiRef$current4;
396
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.requestHide({
397
+ isImmediate: true
398
+ });
399
+ }, []);
393
400
  useNotifyOpenLayerObserver({
394
- isOpen: shouldRenderTooltipPopup
401
+ // Layer is only visually open if both the tooltip popup (container) and children are rendered.
402
+ isOpen: shouldRenderTooltipPopup && (fg('platform_dst_open_layer_observer_close_layers') ? shouldRenderTooltipChildren : true),
403
+ /**
404
+ * We don't strictly need to provide an onClose callback at this time, as there is
405
+ * already code that handles hiding the tooltip when a drag is started (and the only
406
+ * usage right now is closing all layers when the user resizes the side nav).
407
+ *
408
+ * However, for future-proofing and semantic reasons, it makes sense to close the tooltip
409
+ * whenever the open layer observer requests a close.
410
+ */
411
+ onClose: handleOpenLayerObserverCloseSignal
395
412
  });
396
413
  var getReferenceElement = function getReferenceElement() {
397
- var _apiRef$current4;
398
- if (position === 'mouse' && (_apiRef$current4 = apiRef.current) !== null && _apiRef$current4 !== void 0 && _apiRef$current4.mousePosition) {
399
- var _apiRef$current5;
400
- return (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : _apiRef$current5.mousePosition;
414
+ var _apiRef$current5;
415
+ if (position === 'mouse' && (_apiRef$current5 = apiRef.current) !== null && _apiRef$current5 !== void 0 && _apiRef$current5.mousePosition) {
416
+ var _apiRef$current6;
417
+ return (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.mousePosition;
401
418
  }
402
419
  return targetRef.current || undefined;
403
420
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "20.0.4",
3
+ "version": "20.0.5",
4
4
  "description": "A tooltip is a floating, non-actionable label used to explain a user interface element or feature.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -43,8 +43,9 @@
43
43
  "dependencies": {
44
44
  "@atlaskit/analytics-next": "^11.0.0",
45
45
  "@atlaskit/ds-lib": "^4.0.0",
46
- "@atlaskit/layering": "^2.0.0",
46
+ "@atlaskit/layering": "^2.1.0",
47
47
  "@atlaskit/motion": "^5.1.0",
48
+ "@atlaskit/platform-feature-flags": "^1.1.0",
48
49
  "@atlaskit/popper": "^7.0.0",
49
50
  "@atlaskit/portal": "^5.1.0",
50
51
  "@atlaskit/theme": "^18.0.0",
@@ -62,14 +63,14 @@
62
63
  "@af/accessibility-testing": "^2.0.0",
63
64
  "@af/integration-testing": "^0.5.0",
64
65
  "@af/visual-regression": "^1.3.0",
65
- "@atlaskit/button": "^21.1.0",
66
+ "@atlaskit/button": "^22.0.0",
66
67
  "@atlaskit/css": "^0.10.0",
67
68
  "@atlaskit/docs": "^10.0.0",
68
- "@atlaskit/icon": "^25.0.0",
69
- "@atlaskit/link": "^3.0.0",
69
+ "@atlaskit/icon": "^25.4.0",
70
+ "@atlaskit/link": "^3.1.0",
70
71
  "@atlaskit/primitives": "^14.2.0",
71
72
  "@atlaskit/section-message": "^8.2.0",
72
- "@atlaskit/ssr": "^0.4.0",
73
+ "@atlassian/ssr-tests": "^0.2.0",
73
74
  "@testing-library/react": "^13.4.0",
74
75
  "react-dom": "^18.2.0",
75
76
  "tiny-invariant": "^1.2.0",
@@ -99,5 +100,10 @@
99
100
  ]
100
101
  }
101
102
  },
102
- "homepage": "https://atlassian.design/components/tooltip/"
103
+ "homepage": "https://atlassian.design/components/tooltip/",
104
+ "platform-feature-flags": {
105
+ "platform_dst_open_layer_observer_close_layers": {
106
+ "type": "boolean"
107
+ }
108
+ }
103
109
  }