@atlaskit/editor-plugin-type-ahead 7.0.23 → 7.0.25

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,19 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 7.0.25
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 7.0.24
10
+
11
+ ### Patch Changes
12
+
13
+ - [`3a649003f9b55`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3a649003f9b55) -
14
+ [ux] [A11Y-22843] handle Tab and Shift+Tab keypress inside typeahead list
15
+ - Updated dependencies
16
+
3
17
  ## 7.0.23
4
18
 
5
19
  ### Patch Changes
@@ -80,7 +80,7 @@ var isUndoRedoShortcut = function isUndoRedoShortcut(event) {
80
80
  }
81
81
  return false;
82
82
  };
83
- var getAriaLabel = function getAriaLabel(triggerPrefix, intl) {
83
+ var getAriaLabel = function getAriaLabel(triggerPrefix, _intl) {
84
84
  switch (triggerPrefix) {
85
85
  case '@':
86
86
  return _typeAhead.typeAheadListMessages.mentionInputLabel;
@@ -127,7 +127,7 @@ var InputQuery = exports.InputQuery = /*#__PURE__*/_react.default.memo(function
127
127
  var raw = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.textContent) || '';
128
128
  return raw;
129
129
  }, []);
130
- var onKeyUp = (0, _react.useCallback)(function (event) {
130
+ var onKeyUp = (0, _react.useCallback)(function (_event) {
131
131
  var text = cleanedInputContent();
132
132
  onQueryChange(text);
133
133
  }, [onQueryChange, cleanedInputContent]);
@@ -211,21 +211,26 @@ var InputQuery = exports.InputQuery = /*#__PURE__*/_react.default.memo(function
211
211
  }
212
212
  break;
213
213
  case 'Tab':
214
- if (selectedIndex === -1) {
215
- /**
216
- * TODO DTR-1401: (also see ED-17200) There are two options
217
- * here, either
218
- * - set the index directly to 1 in WrapperTypeAhead.tsx's
219
- * `insertSelectedItem` at the cost of breaking some of the a11y
220
- * focus changes,
221
- * - or do this jank at the cost of some small analytics noise.
222
- *
223
- */
224
- selectPreviousItem();
225
- selectNextItem();
214
+ if ((0, _expValEquals.expValEquals)('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
215
+ event.shiftKey ? selectPreviousItem() : selectNextItem();
216
+ break;
217
+ } else {
218
+ if (selectedIndex === -1) {
219
+ /**
220
+ * TODO DTR-1401: (also see ED-17200) There are two options
221
+ * here, either
222
+ * - set the index directly to 1 in WrapperTypeAhead.tsx's
223
+ * `insertSelectedItem` at the cost of breaking some of the a11y
224
+ * focus changes,
225
+ * - or do this jank at the cost of some small analytics noise.
226
+ *
227
+ */
228
+ selectPreviousItem();
229
+ selectNextItem();
230
+ }
231
+ // TODO: DTR-1401 - why is this calling select item when hitting tab? fix this in DTR-1401
232
+ onItemSelect(_typeAhead.SelectItemMode.TAB);
226
233
  }
227
- // TODO: DTR-1401 - why is this calling select item when hitting tab? fix this in DTR-1401
228
- onItemSelect(_typeAhead.SelectItemMode.TAB);
229
234
  break;
230
235
  case 'ArrowDown':
231
236
  selectNextItem();
@@ -252,7 +257,7 @@ var InputQuery = exports.InputQuery = /*#__PURE__*/_react.default.memo(function
252
257
  var element = ref.current;
253
258
  var _ref3 = (0, _utils2.getPluginState)(editorView.state) || {},
254
259
  removePrefixTriggerOnCancel = _ref3.removePrefixTriggerOnCancel;
255
- var onFocusIn = function onFocusIn(event) {
260
+ var onFocusIn = function onFocusIn(_event) {
256
261
  onQueryFocus();
257
262
  };
258
263
  var keyDown = function keyDown(event) {
@@ -8,6 +8,7 @@ var _react = require("react");
8
8
  var _react2 = require("@emotion/react");
9
9
  var _menu = require("@atlaskit/menu");
10
10
  var _colors = require("@atlaskit/theme/colors");
11
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
12
  /**
12
13
  * @jsxRuntime classic
13
14
  * @jsx jsx
@@ -47,7 +48,7 @@ var MoreOptions = exports.MoreOptions = function MoreOptions(_ref) {
47
48
  onClick();
48
49
  // Prevent keydown listener in TypeaheadList from handling Enter pressed
49
50
  e.stopPropagation();
50
- } else if (e.key === 'Tab') {
51
+ } else if (e.key === 'Tab' && !(0, _expValEquals.expValEquals)('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
51
52
  // TypeaheadList will try to insert selected item on Tab press
52
53
  // hence stop propagation to prevent that and treat this as noop
53
54
  e.stopPropagation();
@@ -18,6 +18,7 @@ var _typeAhead = require("@atlaskit/editor-common/type-ahead");
18
18
  var _ui = require("@atlaskit/editor-common/ui");
19
19
  var _menu = require("@atlaskit/menu");
20
20
  var _compiled = require("@atlaskit/primitives/compiled");
21
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
21
22
  var _closeTypeAhead = require("../pm-plugins/commands/close-type-ahead");
22
23
  var _updateSelectedIndex = require("../pm-plugins/commands/update-selected-index");
23
24
  var _constants = require("../pm-plugins/constants");
@@ -100,6 +101,9 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
100
101
  };
101
102
  }, [onItemClick]);
102
103
  var isNavigationKey = function isNavigationKey(event) {
104
+ if ((0, _expValEquals.expValEquals)('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
105
+ return ['ArrowDown', 'ArrowUp', 'Tab', 'Enter', 'Shift'].includes(event.key);
106
+ }
103
107
  return ['ArrowDown', 'ArrowUp', 'Tab', 'Enter'].includes(event.key);
104
108
  };
105
109
  var focusTargetElement = (0, _react.useCallback)(function () {
@@ -232,11 +236,14 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
232
236
  event.preventDefault();
233
237
  event.stopPropagation();
234
238
  break;
235
-
236
- // TODO: DTR-1401 - why is this calling item click when hitting tab? fix this in DTR-1401
237
239
  case 'Tab':
238
- //Tab key quick inserts the selected item.
239
- onItemClick(_typeAhead.SelectItemMode.TAB, selectedIndex, _analytics.INPUT_METHOD.KEYBOARD);
240
+ if ((0, _expValEquals.expValEquals)('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
241
+ event.shiftKey ? selectPreviousItem() : selectNextItem();
242
+ break;
243
+ } else {
244
+ //Tab key quick inserts the selected item.
245
+ onItemClick(_typeAhead.SelectItemMode.TAB, selectedIndex, _analytics.INPUT_METHOD.KEYBOARD);
246
+ }
240
247
  event.preventDefault();
241
248
  break;
242
249
  case 'Enter':
@@ -69,7 +69,7 @@ const isUndoRedoShortcut = event => {
69
69
  }
70
70
  return false;
71
71
  };
72
- const getAriaLabel = (triggerPrefix, intl) => {
72
+ const getAriaLabel = (triggerPrefix, _intl) => {
73
73
  switch (triggerPrefix) {
74
74
  case '@':
75
75
  return typeAheadListMessages.mentionInputLabel;
@@ -113,7 +113,7 @@ export const InputQuery = /*#__PURE__*/React.memo(({
113
113
  const raw = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.textContent) || '';
114
114
  return raw;
115
115
  }, []);
116
- const onKeyUp = useCallback(event => {
116
+ const onKeyUp = useCallback(_event => {
117
117
  const text = cleanedInputContent();
118
118
  onQueryChange(text);
119
119
  }, [onQueryChange, cleanedInputContent]);
@@ -195,21 +195,26 @@ export const InputQuery = /*#__PURE__*/React.memo(({
195
195
  }
196
196
  break;
197
197
  case 'Tab':
198
- if (selectedIndex === -1) {
199
- /**
200
- * TODO DTR-1401: (also see ED-17200) There are two options
201
- * here, either
202
- * - set the index directly to 1 in WrapperTypeAhead.tsx's
203
- * `insertSelectedItem` at the cost of breaking some of the a11y
204
- * focus changes,
205
- * - or do this jank at the cost of some small analytics noise.
206
- *
207
- */
208
- selectPreviousItem();
209
- selectNextItem();
198
+ if (expValEquals('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
199
+ event.shiftKey ? selectPreviousItem() : selectNextItem();
200
+ break;
201
+ } else {
202
+ if (selectedIndex === -1) {
203
+ /**
204
+ * TODO DTR-1401: (also see ED-17200) There are two options
205
+ * here, either
206
+ * - set the index directly to 1 in WrapperTypeAhead.tsx's
207
+ * `insertSelectedItem` at the cost of breaking some of the a11y
208
+ * focus changes,
209
+ * - or do this jank at the cost of some small analytics noise.
210
+ *
211
+ */
212
+ selectPreviousItem();
213
+ selectNextItem();
214
+ }
215
+ // TODO: DTR-1401 - why is this calling select item when hitting tab? fix this in DTR-1401
216
+ onItemSelect(SelectItemMode.TAB);
210
217
  }
211
- // TODO: DTR-1401 - why is this calling select item when hitting tab? fix this in DTR-1401
212
- onItemSelect(SelectItemMode.TAB);
213
218
  break;
214
219
  case 'ArrowDown':
215
220
  selectNextItem();
@@ -239,7 +244,7 @@ export const InputQuery = /*#__PURE__*/React.memo(({
239
244
  const {
240
245
  removePrefixTriggerOnCancel
241
246
  } = getPluginState(editorView.state) || {};
242
- const onFocusIn = event => {
247
+ const onFocusIn = _event => {
243
248
  onQueryFocus();
244
249
  };
245
250
  const keyDown = event => {
@@ -8,6 +8,7 @@ import { useEffect, useRef } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { ButtonItem, Section } from '@atlaskit/menu';
10
10
  import { N30 } from '@atlaskit/theme/colors';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  const buttonStyles = css({
12
13
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
13
14
  '& > button:hover': {
@@ -43,7 +44,7 @@ export const MoreOptions = ({
43
44
  onClick();
44
45
  // Prevent keydown listener in TypeaheadList from handling Enter pressed
45
46
  e.stopPropagation();
46
- } else if (e.key === 'Tab') {
47
+ } else if (e.key === 'Tab' && !expValEquals('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
47
48
  // TypeaheadList will try to insert selected item on Tab press
48
49
  // hence stop propagation to prevent that and treat this as noop
49
50
  e.stopPropagation();
@@ -16,6 +16,7 @@ import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/t
16
16
  import { AssistiveText } from '@atlaskit/editor-common/ui';
17
17
  import { MenuGroup } from '@atlaskit/menu';
18
18
  import { Text, Box } from '@atlaskit/primitives/compiled';
19
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
19
20
  import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
20
21
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
21
22
  import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
@@ -84,6 +85,9 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
84
85
  onItemClick
85
86
  }), [onItemClick]);
86
87
  const isNavigationKey = event => {
88
+ if (expValEquals('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
89
+ return ['ArrowDown', 'ArrowUp', 'Tab', 'Enter', 'Shift'].includes(event.key);
90
+ }
87
91
  return ['ArrowDown', 'ArrowUp', 'Tab', 'Enter'].includes(event.key);
88
92
  };
89
93
  const focusTargetElement = useCallback(() => {
@@ -215,11 +219,14 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
215
219
  event.preventDefault();
216
220
  event.stopPropagation();
217
221
  break;
218
-
219
- // TODO: DTR-1401 - why is this calling item click when hitting tab? fix this in DTR-1401
220
222
  case 'Tab':
221
- //Tab key quick inserts the selected item.
222
- onItemClick(SelectItemMode.TAB, selectedIndex, INPUT_METHOD.KEYBOARD);
223
+ if (expValEquals('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
224
+ event.shiftKey ? selectPreviousItem() : selectNextItem();
225
+ break;
226
+ } else {
227
+ //Tab key quick inserts the selected item.
228
+ onItemClick(SelectItemMode.TAB, selectedIndex, INPUT_METHOD.KEYBOARD);
229
+ }
223
230
  event.preventDefault();
224
231
  break;
225
232
  case 'Enter':
@@ -70,7 +70,7 @@ var isUndoRedoShortcut = function isUndoRedoShortcut(event) {
70
70
  }
71
71
  return false;
72
72
  };
73
- var getAriaLabel = function getAriaLabel(triggerPrefix, intl) {
73
+ var getAriaLabel = function getAriaLabel(triggerPrefix, _intl) {
74
74
  switch (triggerPrefix) {
75
75
  case '@':
76
76
  return typeAheadListMessages.mentionInputLabel;
@@ -117,7 +117,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
117
117
  var raw = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.textContent) || '';
118
118
  return raw;
119
119
  }, []);
120
- var onKeyUp = useCallback(function (event) {
120
+ var onKeyUp = useCallback(function (_event) {
121
121
  var text = cleanedInputContent();
122
122
  onQueryChange(text);
123
123
  }, [onQueryChange, cleanedInputContent]);
@@ -201,21 +201,26 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
201
201
  }
202
202
  break;
203
203
  case 'Tab':
204
- if (selectedIndex === -1) {
205
- /**
206
- * TODO DTR-1401: (also see ED-17200) There are two options
207
- * here, either
208
- * - set the index directly to 1 in WrapperTypeAhead.tsx's
209
- * `insertSelectedItem` at the cost of breaking some of the a11y
210
- * focus changes,
211
- * - or do this jank at the cost of some small analytics noise.
212
- *
213
- */
214
- selectPreviousItem();
215
- selectNextItem();
204
+ if (expValEquals('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
205
+ event.shiftKey ? selectPreviousItem() : selectNextItem();
206
+ break;
207
+ } else {
208
+ if (selectedIndex === -1) {
209
+ /**
210
+ * TODO DTR-1401: (also see ED-17200) There are two options
211
+ * here, either
212
+ * - set the index directly to 1 in WrapperTypeAhead.tsx's
213
+ * `insertSelectedItem` at the cost of breaking some of the a11y
214
+ * focus changes,
215
+ * - or do this jank at the cost of some small analytics noise.
216
+ *
217
+ */
218
+ selectPreviousItem();
219
+ selectNextItem();
220
+ }
221
+ // TODO: DTR-1401 - why is this calling select item when hitting tab? fix this in DTR-1401
222
+ onItemSelect(SelectItemMode.TAB);
216
223
  }
217
- // TODO: DTR-1401 - why is this calling select item when hitting tab? fix this in DTR-1401
218
- onItemSelect(SelectItemMode.TAB);
219
224
  break;
220
225
  case 'ArrowDown':
221
226
  selectNextItem();
@@ -242,7 +247,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
242
247
  var element = ref.current;
243
248
  var _ref3 = getPluginState(editorView.state) || {},
244
249
  removePrefixTriggerOnCancel = _ref3.removePrefixTriggerOnCancel;
245
- var onFocusIn = function onFocusIn(event) {
250
+ var onFocusIn = function onFocusIn(_event) {
246
251
  onQueryFocus();
247
252
  };
248
253
  var keyDown = function keyDown(event) {
@@ -8,6 +8,7 @@ import { useEffect, useRef } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { ButtonItem, Section } from '@atlaskit/menu';
10
10
  import { N30 } from '@atlaskit/theme/colors';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  var buttonStyles = css({
12
13
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
13
14
  '& > button:hover': {
@@ -40,7 +41,7 @@ export var MoreOptions = function MoreOptions(_ref) {
40
41
  onClick();
41
42
  // Prevent keydown listener in TypeaheadList from handling Enter pressed
42
43
  e.stopPropagation();
43
- } else if (e.key === 'Tab') {
44
+ } else if (e.key === 'Tab' && !expValEquals('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
44
45
  // TypeaheadList will try to insert selected item on Tab press
45
46
  // hence stop propagation to prevent that and treat this as noop
46
47
  e.stopPropagation();
@@ -17,6 +17,7 @@ import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/t
17
17
  import { AssistiveText } from '@atlaskit/editor-common/ui';
18
18
  import { MenuGroup } from '@atlaskit/menu';
19
19
  import { Text, Box } from '@atlaskit/primitives/compiled';
20
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
21
  import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
21
22
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
22
23
  import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
@@ -91,6 +92,9 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
91
92
  };
92
93
  }, [onItemClick]);
93
94
  var isNavigationKey = function isNavigationKey(event) {
95
+ if (expValEquals('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
96
+ return ['ArrowDown', 'ArrowUp', 'Tab', 'Enter', 'Shift'].includes(event.key);
97
+ }
94
98
  return ['ArrowDown', 'ArrowUp', 'Tab', 'Enter'].includes(event.key);
95
99
  };
96
100
  var focusTargetElement = useCallback(function () {
@@ -223,11 +227,14 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref2) {
223
227
  event.preventDefault();
224
228
  event.stopPropagation();
225
229
  break;
226
-
227
- // TODO: DTR-1401 - why is this calling item click when hitting tab? fix this in DTR-1401
228
230
  case 'Tab':
229
- //Tab key quick inserts the selected item.
230
- onItemClick(SelectItemMode.TAB, selectedIndex, INPUT_METHOD.KEYBOARD);
231
+ if (expValEquals('platform_editor_a11y_typeahead_tab_keypress', 'isEnabled', true)) {
232
+ event.shiftKey ? selectPreviousItem() : selectNextItem();
233
+ break;
234
+ } else {
235
+ //Tab key quick inserts the selected item.
236
+ onItemClick(SelectItemMode.TAB, selectedIndex, INPUT_METHOD.KEYBOARD);
237
+ }
231
238
  event.preventDefault();
232
239
  break;
233
240
  case 'Enter':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "7.0.23",
3
+ "version": "7.0.25",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.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": "^21.0.0",
48
- "@atlaskit/tmp-editor-statsig": "^31.2.0",
48
+ "@atlaskit/tmp-editor-statsig": "^32.0.0",
49
49
  "@atlaskit/tokens": "^11.0.0",
50
50
  "@atlaskit/visually-hidden": "^3.0.0",
51
51
  "@babel/runtime": "^7.0.0",