@atlaskit/editor-plugin-type-ahead 8.0.5 → 8.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 +8 -0
- package/dist/cjs/ui/MoreOptions.js +17 -4
- package/dist/cjs/ui/TypeAheadList.js +16 -2
- package/dist/cjs/ui/TypeAheadListItem.js +17 -7
- package/dist/es2019/ui/MoreOptions.js +15 -4
- package/dist/es2019/ui/TypeAheadList.js +16 -2
- package/dist/es2019/ui/TypeAheadListItem.js +17 -7
- package/dist/esm/ui/MoreOptions.js +15 -4
- package/dist/esm/ui/TypeAheadList.js +16 -2
- package/dist/esm/ui/TypeAheadListItem.js +17 -7
- package/dist/types/ui/MoreOptions.d.ts +7 -1
- package/dist/types/ui/TypeAheadListItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/MoreOptions.d.ts +7 -1
- package/dist/types-ts4.5/ui/TypeAheadListItem.d.ts +2 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-type-ahead
|
|
2
2
|
|
|
3
|
+
## 8.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1f132a3204f7b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1f132a3204f7b) -
|
|
8
|
+
Fix Safari cursor jumping to start when hovering over typeahead menu items
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 8.0.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.MoreOptions = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _react2 = require("@emotion/react");
|
|
10
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
9
11
|
var _menu = require("@atlaskit/menu");
|
|
10
12
|
var _colors = require("@atlaskit/theme/colors");
|
|
11
13
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
15
|
/**
|
|
13
16
|
* @jsxRuntime classic
|
|
14
17
|
* @jsx jsx
|
|
@@ -31,13 +34,18 @@ var MoreOptions = exports.MoreOptions = function MoreOptions(_ref) {
|
|
|
31
34
|
isFocused = _ref.isFocused,
|
|
32
35
|
title = _ref.title,
|
|
33
36
|
ariaLabel = _ref.ariaLabel,
|
|
34
|
-
iconBefore = _ref.iconBefore
|
|
37
|
+
iconBefore = _ref.iconBefore,
|
|
38
|
+
lastInputMethodRef = _ref.lastInputMethodRef;
|
|
35
39
|
var ref = (0, _react.useRef)(null);
|
|
40
|
+
var isSafari = (0, _browser.getBrowserInfo)().safari;
|
|
36
41
|
(0, _react.useEffect)(function () {
|
|
37
42
|
if (isFocused && ref.current) {
|
|
38
|
-
|
|
43
|
+
var skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && (0, _expValEquals.expValEquals)('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
44
|
+
if (!skipFocusOnSafariHover) {
|
|
45
|
+
ref.current.focus();
|
|
46
|
+
}
|
|
39
47
|
}
|
|
40
|
-
}, [isFocused]);
|
|
48
|
+
}, [isFocused, lastInputMethodRef, isSafari]);
|
|
41
49
|
(0, _react.useEffect)(function () {
|
|
42
50
|
if (!ref.current) {
|
|
43
51
|
return;
|
|
@@ -71,6 +79,11 @@ var MoreOptions = exports.MoreOptions = function MoreOptions(_ref) {
|
|
|
71
79
|
css: buttonStyles
|
|
72
80
|
}, (0, _react2.jsx)(_menu.ButtonItem, {
|
|
73
81
|
ref: ref,
|
|
82
|
+
onMouseDown: function onMouseDown(e) {
|
|
83
|
+
if (isSafari && (0, _expValEquals.expValEquals)('platform_safari_cursor_typeahead_fix', 'isEnabled', true)) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
}
|
|
86
|
+
},
|
|
74
87
|
onClick: onClick,
|
|
75
88
|
iconBefore: iconBefore,
|
|
76
89
|
"aria-label": ariaLabel,
|
|
@@ -71,6 +71,8 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
71
71
|
onMoreOptionsClicked = _ref2.onMoreOptionsClicked;
|
|
72
72
|
var listRef = (0, _react.useRef)();
|
|
73
73
|
var listContainerRef = (0, _react.useRef)(null);
|
|
74
|
+
var lastInputMethodRef = (0, _react.useRef)('keyboard');
|
|
75
|
+
var mouseMovedRef = (0, _react.useRef)(false);
|
|
74
76
|
var lastVisibleIndexes = (0, _react.useRef)({
|
|
75
77
|
overscanStartIndex: 0,
|
|
76
78
|
overscanStopIndex: 0,
|
|
@@ -169,8 +171,17 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
169
171
|
if (selectedIndex === index) {
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
174
|
+
mouseMovedRef.current = true;
|
|
175
|
+
lastInputMethodRef.current = 'mouse';
|
|
172
176
|
(0, _updateSelectedIndex.updateSelectedIndex)(index, api)(editorView.state, editorView.dispatch);
|
|
173
177
|
};
|
|
178
|
+
(0, _react.useLayoutEffect)(function () {
|
|
179
|
+
if (mouseMovedRef.current) {
|
|
180
|
+
mouseMovedRef.current = false;
|
|
181
|
+
} else {
|
|
182
|
+
lastInputMethodRef.current = 'keyboard';
|
|
183
|
+
}
|
|
184
|
+
}, [selectedIndex]);
|
|
174
185
|
(0, _react.useLayoutEffect)(function () {
|
|
175
186
|
if (!listRef.current) {
|
|
176
187
|
return;
|
|
@@ -225,6 +236,7 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
225
236
|
*/
|
|
226
237
|
var handleKeyDown = function handleKeyDown(event) {
|
|
227
238
|
if (isNavigationKey(event)) {
|
|
239
|
+
lastInputMethodRef.current = 'keyboard';
|
|
228
240
|
switch (event.key) {
|
|
229
241
|
case 'ArrowDown':
|
|
230
242
|
selectNextItem();
|
|
@@ -328,7 +340,8 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
328
340
|
},
|
|
329
341
|
ariaLabel: (0, _utils.getTypeAheadListAriaLabels)(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger, intl, currentItem).listItemAriaLabel,
|
|
330
342
|
moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
|
|
331
|
-
api: api
|
|
343
|
+
api: api,
|
|
344
|
+
lastInputMethodRef: lastInputMethodRef
|
|
332
345
|
}));
|
|
333
346
|
});
|
|
334
347
|
};
|
|
@@ -392,7 +405,8 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
|
|
|
392
405
|
ariaLabel: config.ariaLabel,
|
|
393
406
|
onClick: handleClick,
|
|
394
407
|
isFocused: selectedIndex === itemsLength,
|
|
395
|
-
iconBefore: config.iconBefore
|
|
408
|
+
iconBefore: config.iconBefore,
|
|
409
|
+
lastInputMethodRef: lastInputMethodRef
|
|
396
410
|
}), (0, _react2.jsx)(TypeaheadAssistiveTextPureComponent, {
|
|
397
411
|
numberOfResults: itemsLength.toString()
|
|
398
412
|
})));
|
|
@@ -10,6 +10,7 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _reactIntlNext = require("react-intl-next");
|
|
13
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
13
14
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
15
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
15
16
|
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
@@ -18,6 +19,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
18
19
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
19
20
|
var _menu = require("@atlaskit/menu");
|
|
20
21
|
var _colors = require("@atlaskit/theme/colors");
|
|
22
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
21
23
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
22
24
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
23
25
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
@@ -166,7 +168,9 @@ var TypeAheadListItem = exports.TypeAheadListItem = /*#__PURE__*/_react.default.
|
|
|
166
168
|
ariaLabel = _ref.ariaLabel,
|
|
167
169
|
moreElementsInQuickInsertViewEnabled = _ref.moreElementsInQuickInsertViewEnabled,
|
|
168
170
|
api = _ref.api,
|
|
169
|
-
firstOnlineSupportedIndex = _ref.firstOnlineSupportedIndex
|
|
171
|
+
firstOnlineSupportedIndex = _ref.firstOnlineSupportedIndex,
|
|
172
|
+
lastInputMethodRef = _ref.lastInputMethodRef;
|
|
173
|
+
var isSafari = (0, _browser.getBrowserInfo)().safari;
|
|
170
174
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity'], function (states) {
|
|
171
175
|
var _states$connectivityS;
|
|
172
176
|
return {
|
|
@@ -220,16 +224,22 @@ var TypeAheadListItem = exports.TypeAheadListItem = /*#__PURE__*/_react.default.
|
|
|
220
224
|
}, [isSelected, itemIsDisabled]);
|
|
221
225
|
(0, _react.useLayoutEffect)(function () {
|
|
222
226
|
if (shouldUpdateFocus) {
|
|
223
|
-
var
|
|
224
|
-
|
|
227
|
+
var skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && (0, _expValEquals.expValEquals)('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
228
|
+
if (!skipFocusOnSafariHover) {
|
|
229
|
+
var _customItemRef$curren;
|
|
230
|
+
customItemRef === null || customItemRef === void 0 || (_customItemRef$curren = customItemRef.current) === null || _customItemRef$curren === void 0 || _customItemRef$curren.focus();
|
|
231
|
+
}
|
|
225
232
|
}
|
|
226
|
-
}, [customItemRef, shouldUpdateFocus]);
|
|
233
|
+
}, [customItemRef, shouldUpdateFocus, lastInputMethodRef, isSafari]);
|
|
227
234
|
(0, _react.useLayoutEffect)(function () {
|
|
228
235
|
if (shouldUpdateFocus) {
|
|
229
|
-
var
|
|
230
|
-
|
|
236
|
+
var skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && (0, _expValEquals.expValEquals)('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
237
|
+
if (!skipFocusOnSafariHover) {
|
|
238
|
+
var _buttonItemRef$curren;
|
|
239
|
+
buttonItemRef === null || buttonItemRef === void 0 || (_buttonItemRef$curren = buttonItemRef.current) === null || _buttonItemRef$curren === void 0 || _buttonItemRef$curren.focus();
|
|
240
|
+
}
|
|
231
241
|
}
|
|
232
|
-
}, [buttonItemRef, shouldUpdateFocus]);
|
|
242
|
+
}, [buttonItemRef, shouldUpdateFocus, lastInputMethodRef, isSafari]);
|
|
233
243
|
if (customRenderItem) {
|
|
234
244
|
return (0, _react2.jsx)(CustomItemComponentWrapper, {
|
|
235
245
|
itemIsDisabled: itemIsDisabled,
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
import { useEffect, useRef } from 'react';
|
|
5
|
+
import React, { useEffect, useRef } from 'react';
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
|
+
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
9
10
|
import { ButtonItem, Section } from '@atlaskit/menu';
|
|
10
11
|
import { N30 } from '@atlaskit/theme/colors';
|
|
11
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -24,14 +25,19 @@ export const MoreOptions = ({
|
|
|
24
25
|
isFocused,
|
|
25
26
|
title,
|
|
26
27
|
ariaLabel,
|
|
27
|
-
iconBefore
|
|
28
|
+
iconBefore,
|
|
29
|
+
lastInputMethodRef
|
|
28
30
|
}) => {
|
|
29
31
|
const ref = useRef(null);
|
|
32
|
+
const isSafari = getBrowserInfo().safari;
|
|
30
33
|
useEffect(() => {
|
|
31
34
|
if (isFocused && ref.current) {
|
|
32
|
-
|
|
35
|
+
const skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && expValEquals('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
36
|
+
if (!skipFocusOnSafariHover) {
|
|
37
|
+
ref.current.focus();
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
|
-
}, [isFocused]);
|
|
40
|
+
}, [isFocused, lastInputMethodRef, isSafari]);
|
|
35
41
|
useEffect(() => {
|
|
36
42
|
if (!ref.current) {
|
|
37
43
|
return;
|
|
@@ -67,6 +73,11 @@ export const MoreOptions = ({
|
|
|
67
73
|
css: buttonStyles
|
|
68
74
|
}, jsx(ButtonItem, {
|
|
69
75
|
ref: ref,
|
|
76
|
+
onMouseDown: e => {
|
|
77
|
+
if (isSafari && expValEquals('platform_safari_cursor_typeahead_fix', 'isEnabled', true)) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
70
81
|
onClick: onClick,
|
|
71
82
|
iconBefore: iconBefore,
|
|
72
83
|
"aria-label": ariaLabel,
|
|
@@ -63,6 +63,8 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
63
63
|
var _triggerHandler$getMo, _decorationElement$qu2;
|
|
64
64
|
const listRef = useRef();
|
|
65
65
|
const listContainerRef = useRef(null);
|
|
66
|
+
const lastInputMethodRef = useRef('keyboard');
|
|
67
|
+
const mouseMovedRef = useRef(false);
|
|
66
68
|
const lastVisibleIndexes = useRef({
|
|
67
69
|
overscanStartIndex: 0,
|
|
68
70
|
overscanStopIndex: 0,
|
|
@@ -150,8 +152,17 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
150
152
|
if (selectedIndex === index) {
|
|
151
153
|
return;
|
|
152
154
|
}
|
|
155
|
+
mouseMovedRef.current = true;
|
|
156
|
+
lastInputMethodRef.current = 'mouse';
|
|
153
157
|
updateSelectedIndex(index, api)(editorView.state, editorView.dispatch);
|
|
154
158
|
};
|
|
159
|
+
useLayoutEffect(() => {
|
|
160
|
+
if (mouseMovedRef.current) {
|
|
161
|
+
mouseMovedRef.current = false;
|
|
162
|
+
} else {
|
|
163
|
+
lastInputMethodRef.current = 'keyboard';
|
|
164
|
+
}
|
|
165
|
+
}, [selectedIndex]);
|
|
155
166
|
useLayoutEffect(() => {
|
|
156
167
|
if (!listRef.current) {
|
|
157
168
|
return;
|
|
@@ -208,6 +219,7 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
208
219
|
*/
|
|
209
220
|
const handleKeyDown = event => {
|
|
210
221
|
if (isNavigationKey(event)) {
|
|
222
|
+
lastInputMethodRef.current = 'keyboard';
|
|
211
223
|
switch (event.key) {
|
|
212
224
|
case 'ArrowDown':
|
|
213
225
|
selectNextItem();
|
|
@@ -309,7 +321,8 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
309
321
|
},
|
|
310
322
|
ariaLabel: getTypeAheadListAriaLabels(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger, intl, currentItem).listItemAriaLabel,
|
|
311
323
|
moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
|
|
312
|
-
api: api
|
|
324
|
+
api: api,
|
|
325
|
+
lastInputMethodRef: lastInputMethodRef
|
|
313
326
|
})));
|
|
314
327
|
};
|
|
315
328
|
const popupAriaLabel = getTypeAheadListAriaLabels(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger, intl).popupAriaLabel;
|
|
@@ -372,7 +385,8 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
|
|
|
372
385
|
ariaLabel: config.ariaLabel,
|
|
373
386
|
onClick: handleClick,
|
|
374
387
|
isFocused: selectedIndex === itemsLength,
|
|
375
|
-
iconBefore: config.iconBefore
|
|
388
|
+
iconBefore: config.iconBefore,
|
|
389
|
+
lastInputMethodRef: lastInputMethodRef
|
|
376
390
|
}), jsx(TypeaheadAssistiveTextPureComponent, {
|
|
377
391
|
numberOfResults: itemsLength.toString()
|
|
378
392
|
})));
|
|
@@ -7,6 +7,7 @@ import React, { useCallback, useLayoutEffect, useMemo } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { useIntl } from 'react-intl-next';
|
|
10
|
+
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
10
11
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
11
12
|
import { IconFallback } from '@atlaskit/editor-common/quick-insert';
|
|
12
13
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
@@ -15,6 +16,7 @@ import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
|
15
16
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
16
17
|
import { ButtonItem } from '@atlaskit/menu';
|
|
17
18
|
import { B400, N30, N800 } from '@atlaskit/theme/colors';
|
|
19
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
18
20
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
21
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
20
22
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
@@ -175,8 +177,10 @@ export const TypeAheadListItem = /*#__PURE__*/React.memo(({
|
|
|
175
177
|
ariaLabel,
|
|
176
178
|
moreElementsInQuickInsertViewEnabled,
|
|
177
179
|
api,
|
|
178
|
-
firstOnlineSupportedIndex
|
|
180
|
+
firstOnlineSupportedIndex,
|
|
181
|
+
lastInputMethodRef
|
|
179
182
|
}) => {
|
|
183
|
+
const isSafari = getBrowserInfo().safari;
|
|
180
184
|
const {
|
|
181
185
|
connectivityMode
|
|
182
186
|
} = useSharedPluginStateWithSelector(api, ['connectivity'], states => {
|
|
@@ -233,16 +237,22 @@ export const TypeAheadListItem = /*#__PURE__*/React.memo(({
|
|
|
233
237
|
}, [isSelected, itemIsDisabled]);
|
|
234
238
|
useLayoutEffect(() => {
|
|
235
239
|
if (shouldUpdateFocus) {
|
|
236
|
-
|
|
237
|
-
|
|
240
|
+
const skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && expValEquals('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
241
|
+
if (!skipFocusOnSafariHover) {
|
|
242
|
+
var _customItemRef$curren;
|
|
243
|
+
customItemRef === null || customItemRef === void 0 ? void 0 : (_customItemRef$curren = customItemRef.current) === null || _customItemRef$curren === void 0 ? void 0 : _customItemRef$curren.focus();
|
|
244
|
+
}
|
|
238
245
|
}
|
|
239
|
-
}, [customItemRef, shouldUpdateFocus]);
|
|
246
|
+
}, [customItemRef, shouldUpdateFocus, lastInputMethodRef, isSafari]);
|
|
240
247
|
useLayoutEffect(() => {
|
|
241
248
|
if (shouldUpdateFocus) {
|
|
242
|
-
|
|
243
|
-
|
|
249
|
+
const skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && expValEquals('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
250
|
+
if (!skipFocusOnSafariHover) {
|
|
251
|
+
var _buttonItemRef$curren;
|
|
252
|
+
buttonItemRef === null || buttonItemRef === void 0 ? void 0 : (_buttonItemRef$curren = buttonItemRef.current) === null || _buttonItemRef$curren === void 0 ? void 0 : _buttonItemRef$curren.focus();
|
|
253
|
+
}
|
|
244
254
|
}
|
|
245
|
-
}, [buttonItemRef, shouldUpdateFocus]);
|
|
255
|
+
}, [buttonItemRef, shouldUpdateFocus, lastInputMethodRef, isSafari]);
|
|
246
256
|
if (customRenderItem) {
|
|
247
257
|
return jsx(CustomItemComponentWrapper, {
|
|
248
258
|
itemIsDisabled: itemIsDisabled,
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
import { useEffect, useRef } from 'react';
|
|
5
|
+
import React, { useEffect, useRef } from 'react';
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
|
+
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
9
10
|
import { ButtonItem, Section } from '@atlaskit/menu';
|
|
10
11
|
import { N30 } from '@atlaskit/theme/colors';
|
|
11
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -24,13 +25,18 @@ export var MoreOptions = function MoreOptions(_ref) {
|
|
|
24
25
|
isFocused = _ref.isFocused,
|
|
25
26
|
title = _ref.title,
|
|
26
27
|
ariaLabel = _ref.ariaLabel,
|
|
27
|
-
iconBefore = _ref.iconBefore
|
|
28
|
+
iconBefore = _ref.iconBefore,
|
|
29
|
+
lastInputMethodRef = _ref.lastInputMethodRef;
|
|
28
30
|
var ref = useRef(null);
|
|
31
|
+
var isSafari = getBrowserInfo().safari;
|
|
29
32
|
useEffect(function () {
|
|
30
33
|
if (isFocused && ref.current) {
|
|
31
|
-
|
|
34
|
+
var skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && expValEquals('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
35
|
+
if (!skipFocusOnSafariHover) {
|
|
36
|
+
ref.current.focus();
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
|
-
}, [isFocused]);
|
|
39
|
+
}, [isFocused, lastInputMethodRef, isSafari]);
|
|
34
40
|
useEffect(function () {
|
|
35
41
|
if (!ref.current) {
|
|
36
42
|
return;
|
|
@@ -64,6 +70,11 @@ export var MoreOptions = function MoreOptions(_ref) {
|
|
|
64
70
|
css: buttonStyles
|
|
65
71
|
}, jsx(ButtonItem, {
|
|
66
72
|
ref: ref,
|
|
73
|
+
onMouseDown: function onMouseDown(e) {
|
|
74
|
+
if (isSafari && expValEquals('platform_safari_cursor_typeahead_fix', 'isEnabled', true)) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
}
|
|
77
|
+
},
|
|
67
78
|
onClick: onClick,
|
|
68
79
|
iconBefore: iconBefore,
|
|
69
80
|
"aria-label": ariaLabel,
|
|
@@ -62,6 +62,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
62
62
|
onMoreOptionsClicked = _ref2.onMoreOptionsClicked;
|
|
63
63
|
var listRef = useRef();
|
|
64
64
|
var listContainerRef = useRef(null);
|
|
65
|
+
var lastInputMethodRef = useRef('keyboard');
|
|
66
|
+
var mouseMovedRef = useRef(false);
|
|
65
67
|
var lastVisibleIndexes = useRef({
|
|
66
68
|
overscanStartIndex: 0,
|
|
67
69
|
overscanStopIndex: 0,
|
|
@@ -160,8 +162,17 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
160
162
|
if (selectedIndex === index) {
|
|
161
163
|
return;
|
|
162
164
|
}
|
|
165
|
+
mouseMovedRef.current = true;
|
|
166
|
+
lastInputMethodRef.current = 'mouse';
|
|
163
167
|
updateSelectedIndex(index, api)(editorView.state, editorView.dispatch);
|
|
164
168
|
};
|
|
169
|
+
useLayoutEffect(function () {
|
|
170
|
+
if (mouseMovedRef.current) {
|
|
171
|
+
mouseMovedRef.current = false;
|
|
172
|
+
} else {
|
|
173
|
+
lastInputMethodRef.current = 'keyboard';
|
|
174
|
+
}
|
|
175
|
+
}, [selectedIndex]);
|
|
165
176
|
useLayoutEffect(function () {
|
|
166
177
|
if (!listRef.current) {
|
|
167
178
|
return;
|
|
@@ -216,6 +227,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
216
227
|
*/
|
|
217
228
|
var handleKeyDown = function handleKeyDown(event) {
|
|
218
229
|
if (isNavigationKey(event)) {
|
|
230
|
+
lastInputMethodRef.current = 'keyboard';
|
|
219
231
|
switch (event.key) {
|
|
220
232
|
case 'ArrowDown':
|
|
221
233
|
selectNextItem();
|
|
@@ -319,7 +331,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
319
331
|
},
|
|
320
332
|
ariaLabel: getTypeAheadListAriaLabels(triggerHandler === null || triggerHandler === void 0 ? void 0 : triggerHandler.trigger, intl, currentItem).listItemAriaLabel,
|
|
321
333
|
moreElementsInQuickInsertViewEnabled: moreElementsInQuickInsertViewEnabled,
|
|
322
|
-
api: api
|
|
334
|
+
api: api,
|
|
335
|
+
lastInputMethodRef: lastInputMethodRef
|
|
323
336
|
}));
|
|
324
337
|
});
|
|
325
338
|
};
|
|
@@ -383,7 +396,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
383
396
|
ariaLabel: config.ariaLabel,
|
|
384
397
|
onClick: handleClick,
|
|
385
398
|
isFocused: selectedIndex === itemsLength,
|
|
386
|
-
iconBefore: config.iconBefore
|
|
399
|
+
iconBefore: config.iconBefore,
|
|
400
|
+
lastInputMethodRef: lastInputMethodRef
|
|
387
401
|
}), jsx(TypeaheadAssistiveTextPureComponent, {
|
|
388
402
|
numberOfResults: itemsLength.toString()
|
|
389
403
|
})));
|
|
@@ -9,6 +9,7 @@ import React, { useCallback, useLayoutEffect, useMemo } from 'react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
10
10
|
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import { useIntl } from 'react-intl-next';
|
|
12
|
+
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
12
13
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
13
14
|
import { IconFallback } from '@atlaskit/editor-common/quick-insert';
|
|
14
15
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
@@ -17,6 +18,7 @@ import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
|
17
18
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
18
19
|
import { ButtonItem } from '@atlaskit/menu';
|
|
19
20
|
import { B400, N30, N800 } from '@atlaskit/theme/colors';
|
|
21
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
20
22
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
21
23
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
22
24
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
@@ -158,7 +160,9 @@ export var TypeAheadListItem = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
158
160
|
ariaLabel = _ref.ariaLabel,
|
|
159
161
|
moreElementsInQuickInsertViewEnabled = _ref.moreElementsInQuickInsertViewEnabled,
|
|
160
162
|
api = _ref.api,
|
|
161
|
-
firstOnlineSupportedIndex = _ref.firstOnlineSupportedIndex
|
|
163
|
+
firstOnlineSupportedIndex = _ref.firstOnlineSupportedIndex,
|
|
164
|
+
lastInputMethodRef = _ref.lastInputMethodRef;
|
|
165
|
+
var isSafari = getBrowserInfo().safari;
|
|
162
166
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['connectivity'], function (states) {
|
|
163
167
|
var _states$connectivityS;
|
|
164
168
|
return {
|
|
@@ -212,16 +216,22 @@ export var TypeAheadListItem = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
212
216
|
}, [isSelected, itemIsDisabled]);
|
|
213
217
|
useLayoutEffect(function () {
|
|
214
218
|
if (shouldUpdateFocus) {
|
|
215
|
-
var
|
|
216
|
-
|
|
219
|
+
var skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && expValEquals('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
220
|
+
if (!skipFocusOnSafariHover) {
|
|
221
|
+
var _customItemRef$curren;
|
|
222
|
+
customItemRef === null || customItemRef === void 0 || (_customItemRef$curren = customItemRef.current) === null || _customItemRef$curren === void 0 || _customItemRef$curren.focus();
|
|
223
|
+
}
|
|
217
224
|
}
|
|
218
|
-
}, [customItemRef, shouldUpdateFocus]);
|
|
225
|
+
}, [customItemRef, shouldUpdateFocus, lastInputMethodRef, isSafari]);
|
|
219
226
|
useLayoutEffect(function () {
|
|
220
227
|
if (shouldUpdateFocus) {
|
|
221
|
-
var
|
|
222
|
-
|
|
228
|
+
var skipFocusOnSafariHover = isSafari && (lastInputMethodRef === null || lastInputMethodRef === void 0 ? void 0 : lastInputMethodRef.current) === 'mouse' && expValEquals('platform_safari_cursor_typeahead_fix', 'isEnabled', true);
|
|
229
|
+
if (!skipFocusOnSafariHover) {
|
|
230
|
+
var _buttonItemRef$curren;
|
|
231
|
+
buttonItemRef === null || buttonItemRef === void 0 || (_buttonItemRef$curren = buttonItemRef.current) === null || _buttonItemRef$curren === void 0 || _buttonItemRef$curren.focus();
|
|
232
|
+
}
|
|
223
233
|
}
|
|
224
|
-
}, [buttonItemRef, shouldUpdateFocus]);
|
|
234
|
+
}, [buttonItemRef, shouldUpdateFocus, lastInputMethodRef, isSafari]);
|
|
225
235
|
if (customRenderItem) {
|
|
226
236
|
return jsx(CustomItemComponentWrapper, {
|
|
227
237
|
itemIsDisabled: itemIsDisabled,
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
1
6
|
import { jsx } from '@emotion/react';
|
|
2
7
|
type Props = {
|
|
3
8
|
ariaLabel?: string;
|
|
4
9
|
iconBefore?: React.ReactNode;
|
|
5
10
|
isFocused: boolean;
|
|
11
|
+
lastInputMethodRef?: React.MutableRefObject<'mouse' | 'keyboard'>;
|
|
6
12
|
onClick: () => void;
|
|
7
13
|
title: string;
|
|
8
14
|
};
|
|
9
|
-
export declare const MoreOptions: ({ onClick, isFocused, title, ariaLabel, iconBefore, }: Props) => jsx.JSX.Element;
|
|
15
|
+
export declare const MoreOptions: ({ onClick, isFocused, title, ariaLabel, iconBefore, lastInputMethodRef, }: Props) => jsx.JSX.Element;
|
|
10
16
|
export {};
|
|
@@ -15,9 +15,10 @@ type TypeAheadListItemProps = {
|
|
|
15
15
|
item: TypeAheadItem;
|
|
16
16
|
itemIndex: number;
|
|
17
17
|
itemsLength: number;
|
|
18
|
+
lastInputMethodRef?: React.MutableRefObject<'mouse' | 'keyboard'>;
|
|
18
19
|
moreElementsInQuickInsertViewEnabled?: boolean;
|
|
19
20
|
onItemClick: (mode: SelectItemMode, index: number) => void;
|
|
20
21
|
selectedIndex: number;
|
|
21
22
|
};
|
|
22
|
-
export declare const TypeAheadListItem: React.MemoExoticComponent<({ item, itemsLength, selectedIndex, onItemClick, itemIndex, ariaLabel, moreElementsInQuickInsertViewEnabled, api, firstOnlineSupportedIndex, }: TypeAheadListItemProps) => jsx.JSX.Element>;
|
|
23
|
+
export declare const TypeAheadListItem: React.MemoExoticComponent<({ item, itemsLength, selectedIndex, onItemClick, itemIndex, ariaLabel, moreElementsInQuickInsertViewEnabled, api, firstOnlineSupportedIndex, lastInputMethodRef, }: TypeAheadListItemProps) => jsx.JSX.Element>;
|
|
23
24
|
export {};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
1
6
|
import { jsx } from '@emotion/react';
|
|
2
7
|
type Props = {
|
|
3
8
|
ariaLabel?: string;
|
|
4
9
|
iconBefore?: React.ReactNode;
|
|
5
10
|
isFocused: boolean;
|
|
11
|
+
lastInputMethodRef?: React.MutableRefObject<'mouse' | 'keyboard'>;
|
|
6
12
|
onClick: () => void;
|
|
7
13
|
title: string;
|
|
8
14
|
};
|
|
9
|
-
export declare const MoreOptions: ({ onClick, isFocused, title, ariaLabel, iconBefore, }: Props) => jsx.JSX.Element;
|
|
15
|
+
export declare const MoreOptions: ({ onClick, isFocused, title, ariaLabel, iconBefore, lastInputMethodRef, }: Props) => jsx.JSX.Element;
|
|
10
16
|
export {};
|
|
@@ -15,9 +15,10 @@ type TypeAheadListItemProps = {
|
|
|
15
15
|
item: TypeAheadItem;
|
|
16
16
|
itemIndex: number;
|
|
17
17
|
itemsLength: number;
|
|
18
|
+
lastInputMethodRef?: React.MutableRefObject<'mouse' | 'keyboard'>;
|
|
18
19
|
moreElementsInQuickInsertViewEnabled?: boolean;
|
|
19
20
|
onItemClick: (mode: SelectItemMode, index: number) => void;
|
|
20
21
|
selectedIndex: number;
|
|
21
22
|
};
|
|
22
|
-
export declare const TypeAheadListItem: React.MemoExoticComponent<({ item, itemsLength, selectedIndex, onItemClick, itemIndex, ariaLabel, moreElementsInQuickInsertViewEnabled, api, firstOnlineSupportedIndex, }: TypeAheadListItemProps) => jsx.JSX.Element>;
|
|
23
|
+
export declare const TypeAheadListItem: React.MemoExoticComponent<({ item, itemsLength, selectedIndex, onItemClick, itemIndex, ariaLabel, moreElementsInQuickInsertViewEnabled, api, firstOnlineSupportedIndex, lastInputMethodRef, }: TypeAheadListItemProps) => jsx.JSX.Element>;
|
|
23
24
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.6",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"atlaskit:src": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^52.
|
|
32
|
+
"@atlaskit/adf-schema": "^52.4.0",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
34
34
|
"@atlaskit/editor-plugin-connectivity": "^8.0.0",
|
|
35
35
|
"@atlaskit/editor-plugin-context-panel": "^10.0.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
46
46
|
"@atlaskit/prosemirror-input-rules": "^3.6.0",
|
|
47
47
|
"@atlaskit/theme": "^22.0.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^40.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^40.7.0",
|
|
49
49
|
"@atlaskit/tokens": "^11.1.0",
|
|
50
50
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"w3c-keyname": "^2.1.8"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@atlaskit/editor-common": "^112.
|
|
60
|
+
"@atlaskit/editor-common": "^112.6.0",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
63
63
|
"react-intl-next": "npm:react-intl@^5.18.1"
|