@atlaskit/tooltip 20.0.4 → 20.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/tooltip
2
2
 
3
+ ## 20.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#141620](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/141620)
8
+ [`2a925938dea16`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a925938dea16) -
9
+ [ux] Check focus-visible before showing tooltip on focus events
10
+
11
+ ## 20.0.5
12
+
13
+ ### Patch Changes
14
+
15
+ - [#134955](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134955)
16
+ [`ba294ad0536de`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ba294ad0536de) -
17
+ An onClose listener is being provided to the experimental open layer observer.
18
+ - Updated dependencies
19
+
3
20
  ## 20.0.4
4
21
 
5
22
  ### 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.6"
37
38
  };
38
39
 
39
40
  // Inverts motion direction
@@ -374,6 +375,17 @@ function Tooltip(_ref) {
374
375
  }
375
376
  }, []);
376
377
  var onFocus = (0, _react.useCallback)(function () {
378
+ // Check if focus-visible
379
+ // Prevents tooltips from showing when focus is not visible,
380
+ // i.e., when focus is moved onto tooltip trigger inside a popup on open
381
+ try {
382
+ if (targetRef.current && !targetRef.current.matches(':focus-visible') && (0, _platformFeatureFlags.fg)('platform-tooltip-focus-visible')) {
383
+ return;
384
+ }
385
+ } catch (_) {
386
+ // Ignore errors from environments that don't support :focus-visible
387
+ }
388
+
377
389
  // TODO: this does not play well with `hideTooltipOnMouseDown`
378
390
  // as "focus" will occur after the "mousedown".
379
391
  tryShowTooltip({
@@ -400,14 +412,30 @@ function Tooltip(_ref) {
400
412
  var shouldRenderTooltipPopup = state !== 'hide' && Boolean(content);
401
413
  var shouldRenderHiddenContent = !isScreenReaderAnnouncementDisabled && shouldRenderTooltipPopup;
402
414
  var shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
415
+ var handleOpenLayerObserverCloseSignal = (0, _react.useCallback)(function () {
416
+ var _apiRef$current4;
417
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.requestHide({
418
+ isImmediate: true
419
+ });
420
+ }, []);
403
421
  (0, _openLayerObserver.useNotifyOpenLayerObserver)({
404
- isOpen: shouldRenderTooltipPopup
422
+ // Layer is only visually open if both the tooltip popup (container) and children are rendered.
423
+ isOpen: shouldRenderTooltipPopup && ((0, _platformFeatureFlags.fg)('platform_dst_open_layer_observer_close_layers') ? shouldRenderTooltipChildren : true),
424
+ /**
425
+ * We don't strictly need to provide an onClose callback at this time, as there is
426
+ * already code that handles hiding the tooltip when a drag is started (and the only
427
+ * usage right now is closing all layers when the user resizes the side nav).
428
+ *
429
+ * However, for future-proofing and semantic reasons, it makes sense to close the tooltip
430
+ * whenever the open layer observer requests a close.
431
+ */
432
+ onClose: handleOpenLayerObserverCloseSignal
405
433
  });
406
434
  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;
435
+ var _apiRef$current5;
436
+ if (position === 'mouse' && (_apiRef$current5 = apiRef.current) !== null && _apiRef$current5 !== void 0 && _apiRef$current5.mousePosition) {
437
+ var _apiRef$current6;
438
+ return (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.mousePosition;
411
439
  }
412
440
  return targetRef.current || undefined;
413
441
  };
@@ -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.6"
23
24
  };
24
25
 
25
26
  // Inverts motion direction
@@ -349,6 +350,17 @@ function Tooltip({
349
350
  }
350
351
  }, []);
351
352
  const onFocus = useCallback(() => {
353
+ // Check if focus-visible
354
+ // Prevents tooltips from showing when focus is not visible,
355
+ // i.e., when focus is moved onto tooltip trigger inside a popup on open
356
+ try {
357
+ if (targetRef.current && !targetRef.current.matches(':focus-visible') && fg('platform-tooltip-focus-visible')) {
358
+ return;
359
+ }
360
+ } catch (_) {
361
+ // Ignore errors from environments that don't support :focus-visible
362
+ }
363
+
352
364
  // TODO: this does not play well with `hideTooltipOnMouseDown`
353
365
  // as "focus" will occur after the "mousedown".
354
366
  tryShowTooltip({
@@ -375,14 +387,30 @@ function Tooltip({
375
387
  const shouldRenderTooltipPopup = state !== 'hide' && Boolean(content);
376
388
  const shouldRenderHiddenContent = !isScreenReaderAnnouncementDisabled && shouldRenderTooltipPopup;
377
389
  const shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
390
+ const handleOpenLayerObserverCloseSignal = useCallback(() => {
391
+ var _apiRef$current4;
392
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 ? void 0 : _apiRef$current4.requestHide({
393
+ isImmediate: true
394
+ });
395
+ }, []);
378
396
  useNotifyOpenLayerObserver({
379
- isOpen: shouldRenderTooltipPopup
397
+ // Layer is only visually open if both the tooltip popup (container) and children are rendered.
398
+ isOpen: shouldRenderTooltipPopup && (fg('platform_dst_open_layer_observer_close_layers') ? shouldRenderTooltipChildren : true),
399
+ /**
400
+ * We don't strictly need to provide an onClose callback at this time, as there is
401
+ * already code that handles hiding the tooltip when a drag is started (and the only
402
+ * usage right now is closing all layers when the user resizes the side nav).
403
+ *
404
+ * However, for future-proofing and semantic reasons, it makes sense to close the tooltip
405
+ * whenever the open layer observer requests a close.
406
+ */
407
+ onClose: handleOpenLayerObserverCloseSignal
380
408
  });
381
409
  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;
410
+ var _apiRef$current5;
411
+ if (position === 'mouse' && (_apiRef$current5 = apiRef.current) !== null && _apiRef$current5 !== void 0 && _apiRef$current5.mousePosition) {
412
+ var _apiRef$current6;
413
+ return (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.mousePosition;
386
414
  }
387
415
  return targetRef.current || undefined;
388
416
  };
@@ -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.6"
27
28
  };
28
29
 
29
30
  // Inverts motion direction
@@ -364,6 +365,17 @@ function Tooltip(_ref) {
364
365
  }
365
366
  }, []);
366
367
  var onFocus = useCallback(function () {
368
+ // Check if focus-visible
369
+ // Prevents tooltips from showing when focus is not visible,
370
+ // i.e., when focus is moved onto tooltip trigger inside a popup on open
371
+ try {
372
+ if (targetRef.current && !targetRef.current.matches(':focus-visible') && fg('platform-tooltip-focus-visible')) {
373
+ return;
374
+ }
375
+ } catch (_) {
376
+ // Ignore errors from environments that don't support :focus-visible
377
+ }
378
+
367
379
  // TODO: this does not play well with `hideTooltipOnMouseDown`
368
380
  // as "focus" will occur after the "mousedown".
369
381
  tryShowTooltip({
@@ -390,14 +402,30 @@ function Tooltip(_ref) {
390
402
  var shouldRenderTooltipPopup = state !== 'hide' && Boolean(content);
391
403
  var shouldRenderHiddenContent = !isScreenReaderAnnouncementDisabled && shouldRenderTooltipPopup;
392
404
  var shouldRenderTooltipChildren = state !== 'hide' && state !== 'fade-out';
405
+ var handleOpenLayerObserverCloseSignal = useCallback(function () {
406
+ var _apiRef$current4;
407
+ (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 || _apiRef$current4.requestHide({
408
+ isImmediate: true
409
+ });
410
+ }, []);
393
411
  useNotifyOpenLayerObserver({
394
- isOpen: shouldRenderTooltipPopup
412
+ // Layer is only visually open if both the tooltip popup (container) and children are rendered.
413
+ isOpen: shouldRenderTooltipPopup && (fg('platform_dst_open_layer_observer_close_layers') ? shouldRenderTooltipChildren : true),
414
+ /**
415
+ * We don't strictly need to provide an onClose callback at this time, as there is
416
+ * already code that handles hiding the tooltip when a drag is started (and the only
417
+ * usage right now is closing all layers when the user resizes the side nav).
418
+ *
419
+ * However, for future-proofing and semantic reasons, it makes sense to close the tooltip
420
+ * whenever the open layer observer requests a close.
421
+ */
422
+ onClose: handleOpenLayerObserverCloseSignal
395
423
  });
396
424
  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;
425
+ var _apiRef$current5;
426
+ if (position === 'mouse' && (_apiRef$current5 = apiRef.current) !== null && _apiRef$current5 !== void 0 && _apiRef$current5.mousePosition) {
427
+ var _apiRef$current6;
428
+ return (_apiRef$current6 = apiRef.current) === null || _apiRef$current6 === void 0 ? void 0 : _apiRef$current6.mousePosition;
401
429
  }
402
430
  return targetRef.current || undefined;
403
431
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "20.0.4",
3
+ "version": "20.0.6",
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,12 +43,13 @@
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",
51
- "@atlaskit/tokens": "^4.5.0",
52
+ "@atlaskit/tokens": "^4.8.0",
52
53
  "@babel/runtime": "^7.0.0",
53
54
  "@compiled/react": "^0.18.3",
54
55
  "@emotion/react": "^11.7.1",
@@ -59,17 +60,17 @@
59
60
  "react-dom": "^18.2.0"
60
61
  },
61
62
  "devDependencies": {
62
- "@af/accessibility-testing": "^2.0.0",
63
- "@af/integration-testing": "^0.5.0",
64
- "@af/visual-regression": "^1.3.0",
65
- "@atlaskit/button": "^21.1.0",
63
+ "@af/accessibility-testing": "workspace:^",
64
+ "@af/integration-testing": "workspace:^",
65
+ "@af/visual-regression": "workspace:^",
66
+ "@atlaskit/button": "^23.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",
70
- "@atlaskit/primitives": "^14.2.0",
69
+ "@atlaskit/icon": "^25.6.0",
70
+ "@atlaskit/link": "^3.1.0",
71
+ "@atlaskit/primitives": "^14.4.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,13 @@
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
+ "platform-tooltip-focus-visible": {
109
+ "type": "boolean"
110
+ }
111
+ }
103
112
  }