@atlaskit/tooltip 17.8.7 → 17.8.9

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,18 @@
1
1
  # @atlaskit/tooltip
2
2
 
3
+ ## 17.8.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42475](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42475) [`c93c86d4089`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c93c86d4089) - Tooltip no longer throws in an effect when the first child of tooltip isn't an element.
8
+ - [#42475](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42475) [`61779a58ad8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/61779a58ad8) - Tooltip nolonger memoizes the ref callback function for the implicit passing-children-jsx API. The children-as-function API remains memoized. For more control and better performance characteristics we recommend leaning on the explicit children-as-function API over the implicit passing-children-jsx API.
9
+
10
+ ## 17.8.8
11
+
12
+ ### Patch Changes
13
+
14
+ - [#40650](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40650) [`07aa588c8a4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/07aa588c8a4) - Reverts the fix to text descender cut-off, due to incompatibilities with Firefox and Safari.
15
+
3
16
  ## 17.8.7
4
17
 
5
18
  ### Patch Changes
@@ -32,7 +32,7 @@ var tooltipZIndex = _constants.layers.tooltip();
32
32
  var analyticsAttributes = {
33
33
  componentName: 'tooltip',
34
34
  packageName: "@atlaskit/tooltip",
35
- packageVersion: "17.8.7"
35
+ packageVersion: "17.8.9"
36
36
  };
37
37
 
38
38
  // Inverts motion direction
@@ -97,18 +97,18 @@ function Tooltip(_ref) {
97
97
  setState = _useState2[1];
98
98
  var targetRef = (0, _react.useRef)(null);
99
99
  var containerRef = (0, _react.useRef)(null);
100
- var hasFunctionalChildren = typeof children === 'function'; // Stored to keep our `setRef` callback cleaner.
101
- var setRef = (0, _react.useCallback)(function (node) {
102
- if (!node) {
103
- return;
104
- }
105
- if (hasFunctionalChildren) {
106
- targetRef.current = node;
107
- } else {
108
- containerRef.current = node;
109
- targetRef.current = node.firstChild;
110
- }
111
- }, [hasFunctionalChildren]);
100
+
101
+ // This function is deliberately _not_ memoized as it needs to re-run every render
102
+ // to pick up any child ref changes. If you use render props you don't have this issue.
103
+ var setImplicitRefFromChildren = function setImplicitRefFromChildren(node) {
104
+ containerRef.current = node;
105
+ targetRef.current = node ? node.firstElementChild : null;
106
+ };
107
+
108
+ // This is memoized and passed into the render props callback.
109
+ var setDirectRef = (0, _react.useCallback)(function (node) {
110
+ targetRef.current = node;
111
+ }, []);
112
112
 
113
113
  // Putting a few things into refs so that we don't have to break memoization
114
114
  var lastState = (0, _react.useRef)(state);
@@ -202,7 +202,7 @@ function Tooltip(_ref) {
202
202
  }, [abort, done, start]);
203
203
  var hideTooltipOnEsc = (0, _react.useCallback)(function () {
204
204
  var _apiRef$current;
205
- (_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.requestHide({
205
+ (_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 || _apiRef$current.requestHide({
206
206
  isImmediate: true
207
207
  });
208
208
  }, [apiRef]);
@@ -355,8 +355,7 @@ function Tooltip(_ref) {
355
355
  onMouseDown: onMouseDown,
356
356
  onClick: onClick,
357
357
  onFocus: onFocus,
358
- onBlur: onBlur,
359
- ref: setRef
358
+ onBlur: onBlur
360
359
  };
361
360
 
362
361
  // Don't set `data-testid` unless it's defined, as it's not in the interface.
@@ -375,8 +374,6 @@ function Tooltip(_ref) {
375
374
  if (!containerRef.current || !targetRef.current || !tooltipId) {
376
375
  return;
377
376
  }
378
-
379
- // Necessary for TS to know that it has the attribute methods
380
377
  var target = targetRef.current;
381
378
  if (shouldRenderTooltipContainer) {
382
379
  target.setAttribute('aria-describedby', tooltipId);
@@ -389,8 +386,10 @@ function Tooltip(_ref) {
389
386
  // attribute back into the tooltipTriggerProps and make it required
390
387
  // instead of optional in `types`
391
388
  children(_objectSpread(_objectSpread({}, tooltipTriggerProps), {}, {
392
- 'aria-describedby': tooltipId
389
+ 'aria-describedby': tooltipId,
390
+ ref: setDirectRef
393
391
  })) : (0, _react2.jsx)(CastTargetContainer, (0, _extends2.default)({}, tooltipTriggerProps, {
392
+ ref: setImplicitRefFromChildren,
394
393
  role: "presentation"
395
394
  }), children), shouldRenderTooltipContainer ? (0, _react2.jsx)(_portal.default, {
396
395
  zIndex: tooltipZIndex
@@ -427,7 +426,7 @@ function Tooltip(_ref) {
427
426
  style: style,
428
427
  truncate: truncate,
429
428
  placement: tooltipPosition,
430
- testId: testId,
429
+ testId: getReferenceElement() ? testId : testId && "".concat(testId, "--unresolved"),
431
430
  onMouseOut: onMouseOut,
432
431
  onMouseOver: onMouseOverTooltip,
433
432
  id: tooltipId
@@ -438,5 +437,4 @@ function Tooltip(_ref) {
438
437
  })) : null);
439
438
  }
440
439
  Tooltip.displayName = 'Tooltip';
441
- var _default = Tooltip;
442
- exports.default = _default;
440
+ var _default = exports.default = Tooltip;
@@ -26,15 +26,9 @@ var baseStyles = (0, _react2.css)({
26
26
  });
27
27
  var truncateStyles = (0, _react2.css)({
28
28
  maxWidth: '420px',
29
+ overflow: 'hidden',
29
30
  textOverflow: 'ellipsis',
30
- whiteSpace: 'nowrap',
31
- // Use "clip" overflow to allow ellipses on x-axis without clipping descenders
32
- '@supports not (overflow-x: clip)': {
33
- overflow: 'hidden'
34
- },
35
- '@supports (overflow-x: clip)': {
36
- overflowX: 'clip'
37
- }
31
+ whiteSpace: 'nowrap'
38
32
  });
39
33
  var lightStyles = (0, _react2.css)({
40
34
  backgroundColor: "var(--ds-background-neutral-bold, ".concat(_colors.N800, ")"),
@@ -70,5 +64,4 @@ var TooltipContainer = /*#__PURE__*/(0, _react.forwardRef)(function TooltipConta
70
64
  });
71
65
  });
72
66
  TooltipContainer.displayName = 'TooltipContainer';
73
- var _default = TooltipContainer;
74
- exports.default = _default;
67
+ var _default = exports.default = TooltipContainer;
@@ -42,5 +42,4 @@ var TooltipPrimitive = /*#__PURE__*/(0, _react.forwardRef)(function TooltipPrimi
42
42
  }, children));
43
43
  });
44
44
  TooltipPrimitive.displayName = 'TooltipPrimitive';
45
- var _default = TooltipPrimitive;
46
- exports.default = _default;
45
+ var _default = exports.default = TooltipPrimitive;
@@ -20,7 +20,7 @@ const tooltipZIndex = layers.tooltip();
20
20
  const analyticsAttributes = {
21
21
  componentName: 'tooltip',
22
22
  packageName: "@atlaskit/tooltip",
23
- packageVersion: "17.8.7"
23
+ packageVersion: "17.8.9"
24
24
  };
25
25
 
26
26
  // Inverts motion direction
@@ -72,18 +72,18 @@ function Tooltip({
72
72
  const [state, setState] = useState('hide');
73
73
  const targetRef = useRef(null);
74
74
  const containerRef = useRef(null);
75
- const hasFunctionalChildren = typeof children === 'function'; // Stored to keep our `setRef` callback cleaner.
76
- const setRef = useCallback(node => {
77
- if (!node) {
78
- return;
79
- }
80
- if (hasFunctionalChildren) {
81
- targetRef.current = node;
82
- } else {
83
- containerRef.current = node;
84
- targetRef.current = node.firstChild;
85
- }
86
- }, [hasFunctionalChildren]);
75
+
76
+ // This function is deliberately _not_ memoized as it needs to re-run every render
77
+ // to pick up any child ref changes. If you use render props you don't have this issue.
78
+ const setImplicitRefFromChildren = node => {
79
+ containerRef.current = node;
80
+ targetRef.current = node ? node.firstElementChild : null;
81
+ };
82
+
83
+ // This is memoized and passed into the render props callback.
84
+ const setDirectRef = useCallback(node => {
85
+ targetRef.current = node;
86
+ }, []);
87
87
 
88
88
  // Putting a few things into refs so that we don't have to break memoization
89
89
  const lastState = useRef(state);
@@ -332,8 +332,7 @@ function Tooltip({
332
332
  onMouseDown,
333
333
  onClick,
334
334
  onFocus,
335
- onBlur,
336
- ref: setRef
335
+ onBlur
337
336
  };
338
337
 
339
338
  // Don't set `data-testid` unless it's defined, as it's not in the interface.
@@ -352,8 +351,6 @@ function Tooltip({
352
351
  if (!containerRef.current || !targetRef.current || !tooltipId) {
353
352
  return;
354
353
  }
355
-
356
- // Necessary for TS to know that it has the attribute methods
357
354
  const target = targetRef.current;
358
355
  if (shouldRenderTooltipContainer) {
359
356
  target.setAttribute('aria-describedby', tooltipId);
@@ -367,8 +364,10 @@ function Tooltip({
367
364
  // instead of optional in `types`
368
365
  children({
369
366
  ...tooltipTriggerProps,
370
- 'aria-describedby': tooltipId
367
+ 'aria-describedby': tooltipId,
368
+ ref: setDirectRef
371
369
  }) : jsx(CastTargetContainer, _extends({}, tooltipTriggerProps, {
370
+ ref: setImplicitRefFromChildren,
372
371
  role: "presentation"
373
372
  }), children), shouldRenderTooltipContainer ? jsx(Portal, {
374
373
  zIndex: tooltipZIndex
@@ -406,7 +405,7 @@ function Tooltip({
406
405
  style: style,
407
406
  truncate: truncate,
408
407
  placement: tooltipPosition,
409
- testId: testId,
408
+ testId: getReferenceElement() ? testId : testId && `${testId}--unresolved`,
410
409
  onMouseOut: onMouseOut,
411
410
  onMouseOver: onMouseOverTooltip,
412
411
  id: tooltipId
@@ -18,15 +18,9 @@ const baseStyles = css({
18
18
  });
19
19
  const truncateStyles = css({
20
20
  maxWidth: '420px',
21
+ overflow: 'hidden',
21
22
  textOverflow: 'ellipsis',
22
- whiteSpace: 'nowrap',
23
- // Use "clip" overflow to allow ellipses on x-axis without clipping descenders
24
- '@supports not (overflow-x: clip)': {
25
- overflow: 'hidden'
26
- },
27
- '@supports (overflow-x: clip)': {
28
- overflowX: 'clip'
29
- }
23
+ whiteSpace: 'nowrap'
30
24
  });
31
25
  const lightStyles = css({
32
26
  backgroundColor: `var(--ds-background-neutral-bold, ${N800})`,
@@ -24,7 +24,7 @@ var tooltipZIndex = layers.tooltip();
24
24
  var analyticsAttributes = {
25
25
  componentName: 'tooltip',
26
26
  packageName: "@atlaskit/tooltip",
27
- packageVersion: "17.8.7"
27
+ packageVersion: "17.8.9"
28
28
  };
29
29
 
30
30
  // Inverts motion direction
@@ -89,18 +89,18 @@ function Tooltip(_ref) {
89
89
  setState = _useState2[1];
90
90
  var targetRef = useRef(null);
91
91
  var containerRef = useRef(null);
92
- var hasFunctionalChildren = typeof children === 'function'; // Stored to keep our `setRef` callback cleaner.
93
- var setRef = useCallback(function (node) {
94
- if (!node) {
95
- return;
96
- }
97
- if (hasFunctionalChildren) {
98
- targetRef.current = node;
99
- } else {
100
- containerRef.current = node;
101
- targetRef.current = node.firstChild;
102
- }
103
- }, [hasFunctionalChildren]);
92
+
93
+ // This function is deliberately _not_ memoized as it needs to re-run every render
94
+ // to pick up any child ref changes. If you use render props you don't have this issue.
95
+ var setImplicitRefFromChildren = function setImplicitRefFromChildren(node) {
96
+ containerRef.current = node;
97
+ targetRef.current = node ? node.firstElementChild : null;
98
+ };
99
+
100
+ // This is memoized and passed into the render props callback.
101
+ var setDirectRef = useCallback(function (node) {
102
+ targetRef.current = node;
103
+ }, []);
104
104
 
105
105
  // Putting a few things into refs so that we don't have to break memoization
106
106
  var lastState = useRef(state);
@@ -194,7 +194,7 @@ function Tooltip(_ref) {
194
194
  }, [abort, done, start]);
195
195
  var hideTooltipOnEsc = useCallback(function () {
196
196
  var _apiRef$current;
197
- (_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.requestHide({
197
+ (_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 || _apiRef$current.requestHide({
198
198
  isImmediate: true
199
199
  });
200
200
  }, [apiRef]);
@@ -347,8 +347,7 @@ function Tooltip(_ref) {
347
347
  onMouseDown: onMouseDown,
348
348
  onClick: onClick,
349
349
  onFocus: onFocus,
350
- onBlur: onBlur,
351
- ref: setRef
350
+ onBlur: onBlur
352
351
  };
353
352
 
354
353
  // Don't set `data-testid` unless it's defined, as it's not in the interface.
@@ -367,8 +366,6 @@ function Tooltip(_ref) {
367
366
  if (!containerRef.current || !targetRef.current || !tooltipId) {
368
367
  return;
369
368
  }
370
-
371
- // Necessary for TS to know that it has the attribute methods
372
369
  var target = targetRef.current;
373
370
  if (shouldRenderTooltipContainer) {
374
371
  target.setAttribute('aria-describedby', tooltipId);
@@ -381,8 +378,10 @@ function Tooltip(_ref) {
381
378
  // attribute back into the tooltipTriggerProps and make it required
382
379
  // instead of optional in `types`
383
380
  children(_objectSpread(_objectSpread({}, tooltipTriggerProps), {}, {
384
- 'aria-describedby': tooltipId
381
+ 'aria-describedby': tooltipId,
382
+ ref: setDirectRef
385
383
  })) : jsx(CastTargetContainer, _extends({}, tooltipTriggerProps, {
384
+ ref: setImplicitRefFromChildren,
386
385
  role: "presentation"
387
386
  }), children), shouldRenderTooltipContainer ? jsx(Portal, {
388
387
  zIndex: tooltipZIndex
@@ -419,7 +418,7 @@ function Tooltip(_ref) {
419
418
  style: style,
420
419
  truncate: truncate,
421
420
  placement: tooltipPosition,
422
- testId: testId,
421
+ testId: getReferenceElement() ? testId : testId && "".concat(testId, "--unresolved"),
423
422
  onMouseOut: onMouseOut,
424
423
  onMouseOver: onMouseOverTooltip,
425
424
  id: tooltipId
@@ -18,15 +18,9 @@ var baseStyles = css({
18
18
  });
19
19
  var truncateStyles = css({
20
20
  maxWidth: '420px',
21
+ overflow: 'hidden',
21
22
  textOverflow: 'ellipsis',
22
- whiteSpace: 'nowrap',
23
- // Use "clip" overflow to allow ellipses on x-axis without clipping descenders
24
- '@supports not (overflow-x: clip)': {
25
- overflow: 'hidden'
26
- },
27
- '@supports (overflow-x: clip)': {
28
- overflowX: 'clip'
29
- }
23
+ whiteSpace: 'nowrap'
30
24
  });
31
25
  var lightStyles = css({
32
26
  backgroundColor: "var(--ds-background-neutral-bold, ".concat(N800, ")"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.8.7",
3
+ "version": "17.8.9",
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,9 +43,9 @@
43
43
  "@atlaskit/ds-lib": "^2.2.0",
44
44
  "@atlaskit/motion": "^1.5.0",
45
45
  "@atlaskit/popper": "^5.5.0",
46
- "@atlaskit/portal": "^4.3.0",
46
+ "@atlaskit/portal": "^4.4.0",
47
47
  "@atlaskit/theme": "^12.6.0",
48
- "@atlaskit/tokens": "^1.25.0",
48
+ "@atlaskit/tokens": "^1.28.0",
49
49
  "@babel/runtime": "^7.0.0",
50
50
  "@emotion/react": "^11.7.1",
51
51
  "bind-event-listener": "^2.1.1",
@@ -57,13 +57,14 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@af/accessibility-testing": "*",
60
- "@atlaskit/button": "^16.10.0",
60
+ "@atlaskit/button": "^16.12.0",
61
61
  "@atlaskit/ssr": "*",
62
62
  "@atlaskit/visual-regression": "*",
63
63
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
64
64
  "@emotion/styled": "^11.0.0",
65
65
  "@testing-library/dom": "^8.17.1",
66
66
  "@testing-library/react": "^12.1.5",
67
+ "@types/react-redux": "^5.0.0",
67
68
  "jest-in-case": "^1.0.2",
68
69
  "react-dom": "^16.8.0",
69
70
  "react-redux": "^5.1.2",