@atlaskit/tooltip 18.9.0 → 18.9.1
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 +8 -0
- package/dist/cjs/tooltip.js +24 -17
- package/dist/es2019/tooltip.js +24 -17
- package/dist/esm/tooltip.js +24 -17
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/tooltip
|
|
2
2
|
|
|
3
|
+
## 18.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#164322](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/164322)
|
|
8
|
+
[`e9317ed13ba40`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e9317ed13ba40) -
|
|
9
|
+
Internal refactors to state to reduce the number of JavaScript event listeners.
|
|
10
|
+
|
|
3
11
|
## 18.9.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/dist/cjs/tooltip.js
CHANGED
|
@@ -34,7 +34,7 @@ var tooltipZIndex = _constants.layers.tooltip();
|
|
|
34
34
|
var analyticsAttributes = {
|
|
35
35
|
componentName: 'tooltip',
|
|
36
36
|
packageName: "@atlaskit/tooltip",
|
|
37
|
-
packageVersion: "18.9.
|
|
37
|
+
packageVersion: "18.9.1"
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
// Inverts motion direction
|
|
@@ -124,12 +124,13 @@ function Tooltip(_ref) {
|
|
|
124
124
|
|
|
125
125
|
// Putting a few things into refs so that we don't have to break memoization
|
|
126
126
|
var stableState = (0, _useStableRef.default)(state);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
// These props are placed in separate refs instead of a single object to reduce memory usage.
|
|
128
|
+
// Placing them in the same object previously caused an increase in the number of JavaScript event listeners
|
|
129
|
+
// before garbage collection.
|
|
130
|
+
var onShowHandlerStable = (0, _useStableRef.default)(onShowHandler);
|
|
131
|
+
var onHideHandlerStable = (0, _useStableRef.default)(onHideHandler);
|
|
132
|
+
var delayStable = (0, _useStableRef.default)(delay);
|
|
133
|
+
var canAppearStable = (0, _useStableRef.default)(canAppear);
|
|
133
134
|
var hasCalledShowHandler = (0, _react.useRef)(false);
|
|
134
135
|
var start = (0, _react.useCallback)(function (api) {
|
|
135
136
|
// @ts-ignore
|
|
@@ -142,7 +143,7 @@ function Tooltip(_ref) {
|
|
|
142
143
|
}
|
|
143
144
|
// Only call onHideHandler if we have called onShowHandler
|
|
144
145
|
if (hasCalledShowHandler.current) {
|
|
145
|
-
|
|
146
|
+
onHideHandlerStable.current();
|
|
146
147
|
}
|
|
147
148
|
// @ts-ignore
|
|
148
149
|
apiRef.current = null;
|
|
@@ -150,7 +151,7 @@ function Tooltip(_ref) {
|
|
|
150
151
|
hasCalledShowHandler.current = false;
|
|
151
152
|
// just in case
|
|
152
153
|
setState('hide');
|
|
153
|
-
}, [
|
|
154
|
+
}, [onHideHandlerStable]);
|
|
154
155
|
var abort = (0, _react.useCallback)(function () {
|
|
155
156
|
if (!apiRef.current) {
|
|
156
157
|
return;
|
|
@@ -158,11 +159,11 @@ function Tooltip(_ref) {
|
|
|
158
159
|
apiRef.current.abort();
|
|
159
160
|
// Only call onHideHandler if we have called onShowHandler
|
|
160
161
|
if (hasCalledShowHandler.current) {
|
|
161
|
-
|
|
162
|
+
onHideHandlerStable.current();
|
|
162
163
|
}
|
|
163
164
|
// @ts-ignore
|
|
164
165
|
apiRef.current = null;
|
|
165
|
-
}, [
|
|
166
|
+
}, [onHideHandlerStable]);
|
|
166
167
|
(0, _react.useEffect)(function mount() {
|
|
167
168
|
return function unmount() {
|
|
168
169
|
if (apiRef.current) {
|
|
@@ -194,7 +195,7 @@ function Tooltip(_ref) {
|
|
|
194
195
|
});
|
|
195
196
|
}, []);
|
|
196
197
|
var tryShowTooltip = (0, _react.useCallback)(function (source) {
|
|
197
|
-
var
|
|
198
|
+
var _canAppearStable$curr;
|
|
198
199
|
/**
|
|
199
200
|
* Prevent tooltips from being shown during a drag. This can occur with
|
|
200
201
|
* the native drag and drop API, where some pointer events can fire
|
|
@@ -230,18 +231,18 @@ function Tooltip(_ref) {
|
|
|
230
231
|
* where moving the mouse could result in a different outcome to if
|
|
231
232
|
* the mouse was not moved.
|
|
232
233
|
*/
|
|
233
|
-
if (
|
|
234
|
+
if (canAppearStable.current && !((_canAppearStable$curr = canAppearStable.current) !== null && _canAppearStable$curr !== void 0 && _canAppearStable$curr.call(canAppearStable))) {
|
|
234
235
|
return;
|
|
235
236
|
}
|
|
236
237
|
var entry = {
|
|
237
238
|
source: source,
|
|
238
|
-
delay:
|
|
239
|
+
delay: delayStable.current,
|
|
239
240
|
show: function show(_ref3) {
|
|
240
241
|
var isImmediate = _ref3.isImmediate;
|
|
241
242
|
// Call the onShow handler if it hasn't been called yet
|
|
242
243
|
if (!hasCalledShowHandler.current) {
|
|
243
244
|
hasCalledShowHandler.current = true;
|
|
244
|
-
|
|
245
|
+
onShowHandlerStable.current();
|
|
245
246
|
}
|
|
246
247
|
setState(isImmediate ? 'show-immediate' : 'fade-in');
|
|
247
248
|
},
|
|
@@ -257,7 +258,7 @@ function Tooltip(_ref) {
|
|
|
257
258
|
};
|
|
258
259
|
var api = (0, _tooltipManager.show)(entry);
|
|
259
260
|
start(api);
|
|
260
|
-
}, [
|
|
261
|
+
}, [canAppearStable, delayStable, done, start, abort, onShowHandlerStable]);
|
|
261
262
|
var hideTooltipOnEsc = (0, _react.useCallback)(function () {
|
|
262
263
|
var _apiRef$current2;
|
|
263
264
|
(_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 || _apiRef$current2.requestHide({
|
|
@@ -462,7 +463,13 @@ function Tooltip(_ref) {
|
|
|
462
463
|
'aria-describedby': tooltipIdForHiddenContent,
|
|
463
464
|
ref: setDirectRef
|
|
464
465
|
})), hiddenContent) : /*#__PURE__*/_react.default.createElement(CastTargetContainer, (0, _extends2.default)({}, tooltipTriggerProps, {
|
|
465
|
-
ref: setImplicitRefFromChildren
|
|
466
|
+
ref: setImplicitRefFromChildren
|
|
467
|
+
/**
|
|
468
|
+
* TODO: Why is role="presentation" added?
|
|
469
|
+
* - Is it only to "remove" the `Container` from screen readers?
|
|
470
|
+
* - Why is it added only to the `Container` but not to `tooltipTriggerProps`?
|
|
471
|
+
* - Should `role="presentation"` only be used if `shouldRenderHiddenContent == false`?
|
|
472
|
+
*/,
|
|
466
473
|
role: "presentation"
|
|
467
474
|
}), children, hiddenContent), shouldRenderTooltipPopup ? /*#__PURE__*/_react.default.createElement(_portal.default, {
|
|
468
475
|
zIndex: tooltipZIndex
|
package/dist/es2019/tooltip.js
CHANGED
|
@@ -20,7 +20,7 @@ const tooltipZIndex = layers.tooltip();
|
|
|
20
20
|
const analyticsAttributes = {
|
|
21
21
|
componentName: 'tooltip',
|
|
22
22
|
packageName: "@atlaskit/tooltip",
|
|
23
|
-
packageVersion: "18.9.
|
|
23
|
+
packageVersion: "18.9.1"
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
// Inverts motion direction
|
|
@@ -96,12 +96,13 @@ function Tooltip({
|
|
|
96
96
|
|
|
97
97
|
// Putting a few things into refs so that we don't have to break memoization
|
|
98
98
|
const stableState = useStableRef(state);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
// These props are placed in separate refs instead of a single object to reduce memory usage.
|
|
100
|
+
// Placing them in the same object previously caused an increase in the number of JavaScript event listeners
|
|
101
|
+
// before garbage collection.
|
|
102
|
+
const onShowHandlerStable = useStableRef(onShowHandler);
|
|
103
|
+
const onHideHandlerStable = useStableRef(onHideHandler);
|
|
104
|
+
const delayStable = useStableRef(delay);
|
|
105
|
+
const canAppearStable = useStableRef(canAppear);
|
|
105
106
|
const hasCalledShowHandler = useRef(false);
|
|
106
107
|
const start = useCallback(api => {
|
|
107
108
|
// @ts-ignore
|
|
@@ -114,7 +115,7 @@ function Tooltip({
|
|
|
114
115
|
}
|
|
115
116
|
// Only call onHideHandler if we have called onShowHandler
|
|
116
117
|
if (hasCalledShowHandler.current) {
|
|
117
|
-
|
|
118
|
+
onHideHandlerStable.current();
|
|
118
119
|
}
|
|
119
120
|
// @ts-ignore
|
|
120
121
|
apiRef.current = null;
|
|
@@ -122,7 +123,7 @@ function Tooltip({
|
|
|
122
123
|
hasCalledShowHandler.current = false;
|
|
123
124
|
// just in case
|
|
124
125
|
setState('hide');
|
|
125
|
-
}, [
|
|
126
|
+
}, [onHideHandlerStable]);
|
|
126
127
|
const abort = useCallback(() => {
|
|
127
128
|
if (!apiRef.current) {
|
|
128
129
|
return;
|
|
@@ -130,11 +131,11 @@ function Tooltip({
|
|
|
130
131
|
apiRef.current.abort();
|
|
131
132
|
// Only call onHideHandler if we have called onShowHandler
|
|
132
133
|
if (hasCalledShowHandler.current) {
|
|
133
|
-
|
|
134
|
+
onHideHandlerStable.current();
|
|
134
135
|
}
|
|
135
136
|
// @ts-ignore
|
|
136
137
|
apiRef.current = null;
|
|
137
|
-
}, [
|
|
138
|
+
}, [onHideHandlerStable]);
|
|
138
139
|
useEffect(function mount() {
|
|
139
140
|
return function unmount() {
|
|
140
141
|
if (apiRef.current) {
|
|
@@ -167,7 +168,7 @@ function Tooltip({
|
|
|
167
168
|
});
|
|
168
169
|
}, []);
|
|
169
170
|
const tryShowTooltip = useCallback(source => {
|
|
170
|
-
var
|
|
171
|
+
var _canAppearStable$curr;
|
|
171
172
|
/**
|
|
172
173
|
* Prevent tooltips from being shown during a drag. This can occur with
|
|
173
174
|
* the native drag and drop API, where some pointer events can fire
|
|
@@ -203,19 +204,19 @@ function Tooltip({
|
|
|
203
204
|
* where moving the mouse could result in a different outcome to if
|
|
204
205
|
* the mouse was not moved.
|
|
205
206
|
*/
|
|
206
|
-
if (
|
|
207
|
+
if (canAppearStable.current && !((_canAppearStable$curr = canAppearStable.current) !== null && _canAppearStable$curr !== void 0 && _canAppearStable$curr.call(canAppearStable))) {
|
|
207
208
|
return;
|
|
208
209
|
}
|
|
209
210
|
const entry = {
|
|
210
211
|
source,
|
|
211
|
-
delay:
|
|
212
|
+
delay: delayStable.current,
|
|
212
213
|
show: ({
|
|
213
214
|
isImmediate
|
|
214
215
|
}) => {
|
|
215
216
|
// Call the onShow handler if it hasn't been called yet
|
|
216
217
|
if (!hasCalledShowHandler.current) {
|
|
217
218
|
hasCalledShowHandler.current = true;
|
|
218
|
-
|
|
219
|
+
onShowHandlerStable.current();
|
|
219
220
|
}
|
|
220
221
|
setState(isImmediate ? 'show-immediate' : 'fade-in');
|
|
221
222
|
},
|
|
@@ -232,7 +233,7 @@ function Tooltip({
|
|
|
232
233
|
};
|
|
233
234
|
const api = show(entry);
|
|
234
235
|
start(api);
|
|
235
|
-
}, [
|
|
236
|
+
}, [canAppearStable, delayStable, done, start, abort, onShowHandlerStable]);
|
|
236
237
|
const hideTooltipOnEsc = useCallback(() => {
|
|
237
238
|
var _apiRef$current2;
|
|
238
239
|
(_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 ? void 0 : _apiRef$current2.requestHide({
|
|
@@ -436,7 +437,13 @@ function Tooltip({
|
|
|
436
437
|
'aria-describedby': tooltipIdForHiddenContent,
|
|
437
438
|
ref: setDirectRef
|
|
438
439
|
}), hiddenContent) : /*#__PURE__*/React.createElement(CastTargetContainer, _extends({}, tooltipTriggerProps, {
|
|
439
|
-
ref: setImplicitRefFromChildren
|
|
440
|
+
ref: setImplicitRefFromChildren
|
|
441
|
+
/**
|
|
442
|
+
* TODO: Why is role="presentation" added?
|
|
443
|
+
* - Is it only to "remove" the `Container` from screen readers?
|
|
444
|
+
* - Why is it added only to the `Container` but not to `tooltipTriggerProps`?
|
|
445
|
+
* - Should `role="presentation"` only be used if `shouldRenderHiddenContent == false`?
|
|
446
|
+
*/,
|
|
440
447
|
role: "presentation"
|
|
441
448
|
}), children, hiddenContent), shouldRenderTooltipPopup ? /*#__PURE__*/React.createElement(Portal, {
|
|
442
449
|
zIndex: tooltipZIndex
|
package/dist/esm/tooltip.js
CHANGED
|
@@ -24,7 +24,7 @@ var tooltipZIndex = layers.tooltip();
|
|
|
24
24
|
var analyticsAttributes = {
|
|
25
25
|
componentName: 'tooltip',
|
|
26
26
|
packageName: "@atlaskit/tooltip",
|
|
27
|
-
packageVersion: "18.9.
|
|
27
|
+
packageVersion: "18.9.1"
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
// Inverts motion direction
|
|
@@ -114,12 +114,13 @@ function Tooltip(_ref) {
|
|
|
114
114
|
|
|
115
115
|
// Putting a few things into refs so that we don't have to break memoization
|
|
116
116
|
var stableState = useStableRef(state);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
// These props are placed in separate refs instead of a single object to reduce memory usage.
|
|
118
|
+
// Placing them in the same object previously caused an increase in the number of JavaScript event listeners
|
|
119
|
+
// before garbage collection.
|
|
120
|
+
var onShowHandlerStable = useStableRef(onShowHandler);
|
|
121
|
+
var onHideHandlerStable = useStableRef(onHideHandler);
|
|
122
|
+
var delayStable = useStableRef(delay);
|
|
123
|
+
var canAppearStable = useStableRef(canAppear);
|
|
123
124
|
var hasCalledShowHandler = useRef(false);
|
|
124
125
|
var start = useCallback(function (api) {
|
|
125
126
|
// @ts-ignore
|
|
@@ -132,7 +133,7 @@ function Tooltip(_ref) {
|
|
|
132
133
|
}
|
|
133
134
|
// Only call onHideHandler if we have called onShowHandler
|
|
134
135
|
if (hasCalledShowHandler.current) {
|
|
135
|
-
|
|
136
|
+
onHideHandlerStable.current();
|
|
136
137
|
}
|
|
137
138
|
// @ts-ignore
|
|
138
139
|
apiRef.current = null;
|
|
@@ -140,7 +141,7 @@ function Tooltip(_ref) {
|
|
|
140
141
|
hasCalledShowHandler.current = false;
|
|
141
142
|
// just in case
|
|
142
143
|
setState('hide');
|
|
143
|
-
}, [
|
|
144
|
+
}, [onHideHandlerStable]);
|
|
144
145
|
var abort = useCallback(function () {
|
|
145
146
|
if (!apiRef.current) {
|
|
146
147
|
return;
|
|
@@ -148,11 +149,11 @@ function Tooltip(_ref) {
|
|
|
148
149
|
apiRef.current.abort();
|
|
149
150
|
// Only call onHideHandler if we have called onShowHandler
|
|
150
151
|
if (hasCalledShowHandler.current) {
|
|
151
|
-
|
|
152
|
+
onHideHandlerStable.current();
|
|
152
153
|
}
|
|
153
154
|
// @ts-ignore
|
|
154
155
|
apiRef.current = null;
|
|
155
|
-
}, [
|
|
156
|
+
}, [onHideHandlerStable]);
|
|
156
157
|
useEffect(function mount() {
|
|
157
158
|
return function unmount() {
|
|
158
159
|
if (apiRef.current) {
|
|
@@ -184,7 +185,7 @@ function Tooltip(_ref) {
|
|
|
184
185
|
});
|
|
185
186
|
}, []);
|
|
186
187
|
var tryShowTooltip = useCallback(function (source) {
|
|
187
|
-
var
|
|
188
|
+
var _canAppearStable$curr;
|
|
188
189
|
/**
|
|
189
190
|
* Prevent tooltips from being shown during a drag. This can occur with
|
|
190
191
|
* the native drag and drop API, where some pointer events can fire
|
|
@@ -220,18 +221,18 @@ function Tooltip(_ref) {
|
|
|
220
221
|
* where moving the mouse could result in a different outcome to if
|
|
221
222
|
* the mouse was not moved.
|
|
222
223
|
*/
|
|
223
|
-
if (
|
|
224
|
+
if (canAppearStable.current && !((_canAppearStable$curr = canAppearStable.current) !== null && _canAppearStable$curr !== void 0 && _canAppearStable$curr.call(canAppearStable))) {
|
|
224
225
|
return;
|
|
225
226
|
}
|
|
226
227
|
var entry = {
|
|
227
228
|
source: source,
|
|
228
|
-
delay:
|
|
229
|
+
delay: delayStable.current,
|
|
229
230
|
show: function show(_ref3) {
|
|
230
231
|
var isImmediate = _ref3.isImmediate;
|
|
231
232
|
// Call the onShow handler if it hasn't been called yet
|
|
232
233
|
if (!hasCalledShowHandler.current) {
|
|
233
234
|
hasCalledShowHandler.current = true;
|
|
234
|
-
|
|
235
|
+
onShowHandlerStable.current();
|
|
235
236
|
}
|
|
236
237
|
setState(isImmediate ? 'show-immediate' : 'fade-in');
|
|
237
238
|
},
|
|
@@ -247,7 +248,7 @@ function Tooltip(_ref) {
|
|
|
247
248
|
};
|
|
248
249
|
var api = show(entry);
|
|
249
250
|
start(api);
|
|
250
|
-
}, [
|
|
251
|
+
}, [canAppearStable, delayStable, done, start, abort, onShowHandlerStable]);
|
|
251
252
|
var hideTooltipOnEsc = useCallback(function () {
|
|
252
253
|
var _apiRef$current2;
|
|
253
254
|
(_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 || _apiRef$current2.requestHide({
|
|
@@ -452,7 +453,13 @@ function Tooltip(_ref) {
|
|
|
452
453
|
'aria-describedby': tooltipIdForHiddenContent,
|
|
453
454
|
ref: setDirectRef
|
|
454
455
|
})), hiddenContent) : /*#__PURE__*/React.createElement(CastTargetContainer, _extends({}, tooltipTriggerProps, {
|
|
455
|
-
ref: setImplicitRefFromChildren
|
|
456
|
+
ref: setImplicitRefFromChildren
|
|
457
|
+
/**
|
|
458
|
+
* TODO: Why is role="presentation" added?
|
|
459
|
+
* - Is it only to "remove" the `Container` from screen readers?
|
|
460
|
+
* - Why is it added only to the `Container` but not to `tooltipTriggerProps`?
|
|
461
|
+
* - Should `role="presentation"` only be used if `shouldRenderHiddenContent == false`?
|
|
462
|
+
*/,
|
|
456
463
|
role: "presentation"
|
|
457
464
|
}), children, hiddenContent), shouldRenderTooltipPopup ? /*#__PURE__*/React.createElement(Portal, {
|
|
458
465
|
zIndex: tooltipZIndex
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/tooltip",
|
|
3
|
-
"version": "18.9.
|
|
3
|
+
"version": "18.9.1",
|
|
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/"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
43
43
|
"@atlaskit/ds-lib": "^3.2.0",
|
|
44
|
-
"@atlaskit/layering": "^0.7.
|
|
44
|
+
"@atlaskit/layering": "^0.7.3",
|
|
45
45
|
"@atlaskit/motion": "^1.9.0",
|
|
46
46
|
"@atlaskit/popper": "^6.3.0",
|
|
47
47
|
"@atlaskit/portal": "^4.9.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"jest-in-case": "^1.0.2",
|
|
69
69
|
"react-dom": "^16.8.0",
|
|
70
70
|
"react-redux": "^5.1.2",
|
|
71
|
-
"storybook-addon-performance": "^0.
|
|
71
|
+
"storybook-addon-performance": "^0.17.3",
|
|
72
72
|
"typescript": "~5.4.2",
|
|
73
73
|
"wait-for-expect": "^1.2.0"
|
|
74
74
|
},
|