@atlaskit/editor-plugin-quick-insert 22.0.9 → 22.0.10

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,14 @@
1
1
  # @atlaskit/editor-plugin-quick-insert
2
2
 
3
+ ## 22.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b90341d10ef81`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b90341d10ef81) -
8
+ Fix element browser cards, keyboard selection, and small-screen categories under
9
+ platform_editor_slash_command
10
+ - Updated dependencies
11
+
3
12
  ## 22.0.9
4
13
 
5
14
  ### Patch Changes
@@ -1,6 +1,8 @@
1
1
  ._zulp1ejb{gap:var(--ds-space-300,24px)}
2
- ._zulp1fka{gap:calc(var(--ds-space-200, 1pc) + var(--ds-space-150, 9pt))}._1bsb1osq{width:100%}
2
+ ._zulp1fka{gap:calc(var(--ds-space-200, 1pc) + var(--ds-space-150, 9pt))}._18zr1b66{padding-inline:var(--ds-space-050,4px)}
3
+ ._1bsb1osq{width:100%}
3
4
  ._1e0c11p5{display:grid}
5
+ ._1q511b66{padding-block-start:var(--ds-space-050,4px)}
4
6
  ._4cvr1h6o{align-items:center}
5
7
  ._yv0e1xuv{grid-template-columns:182px minmax(0,1fr)}
6
8
  ._yv0ehpfy{grid-template-columns:minmax(0,1fr) auto}
@@ -39,6 +39,14 @@ var headerContentStyles = null;
39
39
  var headerSearchStyles = null;
40
40
  var resultsId = 'registry-element-browser-results';
41
41
  var modalTestId = 'registry-element-browser-modal';
42
+ var getRenderedColumnCount = function getRenderedColumnCount(options) {
43
+ var _options$;
44
+ var firstRowTop = (_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.getBoundingClientRect().top;
45
+ var nextRowIndex = options.findIndex(function (option) {
46
+ return firstRowTop !== undefined && option.getBoundingClientRect().top > firstRowTop + 1;
47
+ });
48
+ return nextRowIndex > 0 ? nextRowIndex : options.length;
49
+ };
42
50
  var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryElementBrowser(_ref) {
43
51
  var _model$fallbackItems$, _model$fallbackItems;
44
52
  var components = _ref.components,
@@ -84,6 +92,7 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
84
92
  selectedKey = _useState6[0],
85
93
  setSelectedKey = _useState6[1];
86
94
  var searchInputRef = (0, _react.useRef)(null);
95
+ var selectedCategoryRef = (0, _react.useRef)(null);
87
96
  var wasOpen = (0, _react.useRef)(false);
88
97
  var previousIsOffline = (0, _react.useRef)(isOffline);
89
98
  (0, _react.useEffect)(function () {
@@ -139,18 +148,40 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
139
148
  scrollableBody === null || scrollableBody === void 0 || scrollableBody.style.setProperty('border-block-end', 'none');
140
149
  }, []);
141
150
  var onKeyDown = (0, _react.useCallback)(function (event) {
142
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
151
+ if (event.key === 'Tab' && event.shiftKey && event.target instanceof HTMLElement && event.target.getAttribute('role') === 'option') {
152
+ var _selectedCategoryRef$;
153
+ event.preventDefault();
154
+ (_selectedCategoryRef$ = selectedCategoryRef.current) === null || _selectedCategoryRef$ === void 0 || _selectedCategoryRef$.focus();
155
+ return;
156
+ }
157
+ if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
143
158
  var _resultCollection$que;
159
+ if (event.currentTarget === searchInputRef.current && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
160
+ return;
161
+ }
144
162
  var resultCollection = event.currentTarget.ownerDocument.getElementById(resultsId);
145
- var options = Array.from((_resultCollection$que = resultCollection === null || resultCollection === void 0 ? void 0 : resultCollection.querySelectorAll('[role="option"]:not([aria-disabled="true"]):not([disabled])')) !== null && _resultCollection$que !== void 0 ? _resultCollection$que : []);
163
+ var options = Array.from((_resultCollection$que = resultCollection === null || resultCollection === void 0 ? void 0 : resultCollection.querySelectorAll('[role="option"]')) !== null && _resultCollection$que !== void 0 ? _resultCollection$que : []);
146
164
  var currentIndex = options.findIndex(function (option) {
147
165
  return option === event.currentTarget.ownerDocument.activeElement;
148
166
  });
149
- var nextIndex = event.key === 'ArrowDown' ? currentIndex + 1 : currentIndex - 1;
150
- var nextOption = options.at(nextIndex);
167
+ var columnCount = getRenderedColumnCount(options);
168
+ var step = event.key === 'ArrowDown' ? columnCount : event.key === 'ArrowUp' ? -columnCount : event.key === 'ArrowRight' ? 1 : -1;
169
+ var nextIndex = currentIndex < 0 ? 0 : currentIndex + step;
170
+ if (event.key === 'ArrowDown' && columnCount < options.length) {
171
+ nextIndex = Math.min(nextIndex, options.length - 1);
172
+ }
173
+ while (nextIndex >= 0 && nextIndex < options.length && (options[nextIndex].hasAttribute('disabled') || options[nextIndex].getAttribute('aria-disabled') === 'true')) {
174
+ nextIndex += step;
175
+ }
176
+ var nextOption = options[nextIndex];
151
177
  if (nextOption) {
152
178
  event.preventDefault();
153
179
  nextOption.focus();
180
+ nextOption.click();
181
+ } else if (nextIndex < 0 && currentIndex >= 0) {
182
+ var _searchInputRef$curre;
183
+ event.preventDefault();
184
+ (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 || _searchInputRef$curre.focus();
154
185
  }
155
186
  return;
156
187
  }
@@ -159,9 +190,18 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
159
190
  onClose();
160
191
  return;
161
192
  }
162
- if (event.key === 'Enter' && selectedKey) {
163
- event.preventDefault();
164
- onConfirmInsert();
193
+ if (event.key === 'Enter') {
194
+ var _event$currentTarget$;
195
+ var focusedOption = event.target instanceof HTMLElement ? event.target.closest('[role="option"]') : null;
196
+ var firstOption = (_event$currentTarget$ = event.currentTarget.ownerDocument.getElementById(resultsId)) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.querySelector('[role="option"]:not([aria-disabled="true"]):not([disabled])');
197
+ var optionToActivate = focusedOption !== null && focusedOption !== void 0 ? focusedOption : firstOption;
198
+ if (selectedKey || optionToActivate) {
199
+ event.preventDefault();
200
+ if (!selectedKey) {
201
+ optionToActivate === null || optionToActivate === void 0 || optionToActivate.click();
202
+ }
203
+ onConfirmInsert();
204
+ }
165
205
  }
166
206
  }, [onClose, onConfirmInsert, selectedKey]);
167
207
  return /*#__PURE__*/_react.default.createElement(_modalTransition.default, null, isOpen && /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
@@ -207,11 +247,12 @@ var RegistryElementBrowser = exports.RegistryElementBrowser = function RegistryE
207
247
  onClick: onClose,
208
248
  spacing: "compact"
209
249
  })))), /*#__PURE__*/_react.default.createElement(_modalBody.default, null, /*#__PURE__*/_react.default.createElement("div", {
210
- className: (0, _runtime.ax)(["_zulp1fka _1e0c11p5 _yv0e1xuv _lk4ji47z"])
250
+ className: (0, _runtime.ax)(["_zulp1fka _18zr1b66 _1e0c11p5 _yv0e1xuv _1q511b66 _lk4ji47z"])
211
251
  }, /*#__PURE__*/_react.default.createElement(_RegistryElementBrowserCategories.RegistryElementBrowserCategories, {
212
252
  section: section,
213
253
  sections: model.sections,
214
- onSectionClick: onSectionClick
254
+ onSectionClick: onSectionClick,
255
+ selectedButtonRef: selectedCategoryRef
215
256
  }), /*#__PURE__*/_react.default.createElement(_RegistryElementBrowserSearchResults.RegistryElementBrowserSearchResults, {
216
257
  editorView: editorView,
217
258
  emptyStateHandler: emptyStateHandler,
@@ -1,7 +1,10 @@
1
- ._zulpu2gc{gap:var(--ds-space-100,8px)}._154iv77o{top:var(--ds-space-025,2px)}
1
+ ._zulpu2gc{gap:var(--ds-space-100,8px)}
2
+ ._18zr1b66{padding-inline:var(--ds-space-050,4px)}
3
+ ._1rjc1b66{padding-block:var(--ds-space-050,4px)}._154iidpf{top:0}
2
4
  ._1e0c11p5{display:grid}
5
+ ._1ul9idpf{min-width:0}
3
6
  ._1wpzv2br{align-self:start}
4
7
  ._ae4vv2br{align-content:start}
5
8
  ._kqsw1if8{position:sticky}
6
9
  ._yv0ei47z{grid-template-columns:minmax(0,1fr)}
7
- @media (max-width:599px){._qs0g1bhr{background-color:var(--ds-surface-overlay,#fff)}._1w2e1ris{grid-auto-columns:max-content}._1ato1bp4{grid-auto-flow:column}._lk4jglyw{grid-template-columns:none}._1cgyi47z{grid-template-rows:minmax(0,1fr)}._1s8e1wug{overflow-x:auto}._pevy15vq{overflow-y:hidden}._zvu9kb7n{z-index:1}}
10
+ @media (max-width:599px){._qs0g1bhr{background-color:var(--ds-surface-overlay,#fff)}._1w2e1ris{grid-auto-columns:max-content}._1ato1bp4{grid-auto-flow:column}._lk4jglyw{grid-template-columns:none}._1cgyi47z{grid-template-rows:minmax(0,1fr)}._1s8e1wug{overflow-x:auto}._pevy15vq{overflow-y:hidden}._dl261osq{width:100%}._zvu9kb7n{z-index:1}}
@@ -2,6 +2,7 @@
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
6
  Object.defineProperty(exports, "__esModule", {
6
7
  value: true
7
8
  });
@@ -9,35 +10,54 @@ exports.RegistryElementBrowserCategories = void 0;
9
10
  require("./RegistryElementBrowserCategories.compiled.css");
10
11
  var _runtime = require("@compiled/react/runtime");
11
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- var _react = _interopRequireDefault(require("react"));
13
+ var _react = _interopRequireWildcard(require("react"));
13
14
  var _reactIntl = require("react-intl");
14
15
  var _button = _interopRequireDefault(require("@atlaskit/button/default/button"));
15
16
  var _keys = require("@atlaskit/editor-common/quick-insert/keys");
16
17
  var _messages = require("@atlaskit/editor-common/quick-insert/messages");
17
18
  var _text = require("@atlaskit/primitives/compiled/text");
19
+ 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); }
18
20
  var sectionMessages = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _keys.BLOCK_TEMPLATES_SECTION.key, _messages.messages.categoryBlockTemplates), _keys.DATA_AND_CHARTS_SECTION.key, _messages.messages.categoryDataAndCharts), _keys.EMBED_SECTION.key, _messages.messages.categoryEmbed), _keys.MEDIA_SECTION.key, _messages.messages.categoryMedia), _keys.OTHER_SECTION.key, _messages.messages.categoryOther), _keys.ROVO_SECTION.key, _messages.messages.categoryRovo), _keys.STRUCTURE_SECTION.key, _messages.messages.categoryStructure), _keys.TEXT_FORMATTING_SECTION.key, _messages.messages.categoryTextFormatting);
19
21
  var categoryGridStyles = null;
20
22
  var RegistryElementBrowserCategories = exports.RegistryElementBrowserCategories = function RegistryElementBrowserCategories(_ref) {
21
23
  var section = _ref.section,
22
24
  sections = _ref.sections,
23
- onSectionClick = _ref.onSectionClick;
25
+ onSectionClick = _ref.onSectionClick,
26
+ selectedButtonRef = _ref.selectedButtonRef;
24
27
  var _useIntl = (0, _reactIntl.useIntl)(),
25
28
  formatMessage = _useIntl.formatMessage;
26
29
  var isAllSelected = section === undefined;
30
+ var onCategoryKeyDown = (0, _react.useCallback)(function (event) {
31
+ var _event$currentTarget$, _event$currentTarget$2, _event$currentTarget$3, _event$currentTarget$4;
32
+ if (!['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
33
+ return;
34
+ }
35
+ var isForward = event.key === 'ArrowDown' || event.key === 'ArrowRight';
36
+ var nextButton = isForward ? (_event$currentTarget$ = event.currentTarget.nextElementSibling) !== null && _event$currentTarget$ !== void 0 ? _event$currentTarget$ : (_event$currentTarget$2 = event.currentTarget.parentElement) === null || _event$currentTarget$2 === void 0 ? void 0 : _event$currentTarget$2.firstElementChild : (_event$currentTarget$3 = event.currentTarget.previousElementSibling) !== null && _event$currentTarget$3 !== void 0 ? _event$currentTarget$3 : (_event$currentTarget$4 = event.currentTarget.parentElement) === null || _event$currentTarget$4 === void 0 ? void 0 : _event$currentTarget$4.lastElementChild;
37
+ if (nextButton) {
38
+ event.preventDefault();
39
+ nextButton.focus();
40
+ nextButton.click();
41
+ }
42
+ }, []);
27
43
  return /*#__PURE__*/_react.default.createElement("div", {
28
44
  "aria-label": formatMessage({
29
45
  defaultMessage: 'Element categories',
30
46
  id: 'editor.quick-insert.categories-label'
31
47
  }),
32
48
  "data-testid": "registry-element-browser-categories",
33
- className: (0, _runtime.ax)(["_zulpu2gc _ae4vv2br _1wpzv2br _1e0c11p5 _yv0ei47z _kqsw1if8 _154iv77o _qs0g1bhr _1w2e1ris _1ato1bp4 _lk4jglyw _1cgyi47z _1s8e1wug _pevy15vq _zvu9kb7n"])
49
+ role: "group",
50
+ className: (0, _runtime.ax)(["_zulpu2gc _1rjc1b66 _18zr1b66 _ae4vv2br _1wpzv2br _1e0c11p5 _yv0ei47z _1ul9idpf _kqsw1if8 _154iidpf _qs0g1bhr _1w2e1ris _1ato1bp4 _lk4jglyw _1cgyi47z _1s8e1wug _pevy15vq _dl261osq _zvu9kb7n"])
34
51
  }, /*#__PURE__*/_react.default.createElement(_button.default, {
35
52
  appearance: 'subtle',
36
53
  "aria-pressed": isAllSelected,
37
54
  "data-section": "",
38
55
  onClick: onSectionClick,
56
+ onKeyDown: onCategoryKeyDown,
57
+ ref: isAllSelected ? selectedButtonRef : undefined,
39
58
  isSelected: isAllSelected,
40
- shouldFitContainer: true
59
+ shouldFitContainer: true,
60
+ tabIndex: isAllSelected ? 0 : -1
41
61
  }, /*#__PURE__*/_react.default.createElement(_text.Text, {
42
62
  align: "start",
43
63
  color: "inherit",
@@ -54,8 +74,11 @@ var RegistryElementBrowserCategories = exports.RegistryElementBrowserCategories
54
74
  "data-section": entry.key,
55
75
  key: entry.key,
56
76
  onClick: onSectionClick,
77
+ onKeyDown: onCategoryKeyDown,
78
+ ref: section === entry.key ? selectedButtonRef : undefined,
57
79
  isSelected: section === entry.key,
58
- shouldFitContainer: true
80
+ shouldFitContainer: true,
81
+ tabIndex: section === entry.key ? 0 : -1
59
82
  }, /*#__PURE__*/_react.default.createElement(_text.Text, {
60
83
  align: "start",
61
84
  color: "inherit",
@@ -81,7 +81,7 @@ var RegistryElementBrowserSearchResults = exports.RegistryElementBrowserSearchRe
81
81
  defaultMessage: 'Element results',
82
82
  id: 'editor.quick-insert.results-label'
83
83
  });
84
- var displayedItems = hasFallbackItems ? fallbackItems !== null && fallbackItems !== void 0 ? fallbackItems : [] : items;
84
+ var displayedItems = hasFallbackItems && fallbackItems ? fallbackItems : items;
85
85
  var shouldRenderEmptyState = items.length === 0 && !isLoading;
86
86
  var emptyState = shouldRenderEmptyState ? (_emptyStateHandler = emptyStateHandler === null || emptyStateHandler === void 0 ? void 0 : emptyStateHandler(_objectSpread({
87
87
  mode: 'full',
@@ -117,9 +117,15 @@ var RegistryElementBrowserSearchResults = exports.RegistryElementBrowserSearchRe
117
117
  tabIndex: -1
118
118
  }, displayedItems.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
119
119
  "aria-label": resultsLabel,
120
+ onFocus: function onFocus(event) {
121
+ if (event.target === event.currentTarget) {
122
+ var _event$currentTarget$;
123
+ (_event$currentTarget$ = event.currentTarget.querySelector('[role="option"]:not([aria-disabled="true"]):not([disabled])')) === null || _event$currentTarget$ === void 0 || _event$currentTarget$.focus();
124
+ }
125
+ },
120
126
  onKeyDown: onKeyDown,
121
127
  role: "listbox",
122
- tabIndex: -1,
128
+ tabIndex: 0,
123
129
  className: (0, _runtime.ax)(["_zulpu2gc _ae4vv2br _4cvrv2br _1e0c11p5 _yv0ei47z _16409sye _g98o1koq"])
124
130
  }, displayedItems.map(function (item) {
125
131
  return /*#__PURE__*/_react.default.createElement(RegistryElementBrowserItem, {
@@ -1,6 +1,8 @@
1
1
  ._zulp1ejb{gap:var(--ds-space-300,24px)}
2
- ._zulp1fka{gap:calc(var(--ds-space-200, 1pc) + var(--ds-space-150, 9pt))}._1bsb1osq{width:100%}
2
+ ._zulp1fka{gap:calc(var(--ds-space-200, 1pc) + var(--ds-space-150, 9pt))}._18zr1b66{padding-inline:var(--ds-space-050,4px)}
3
+ ._1bsb1osq{width:100%}
3
4
  ._1e0c11p5{display:grid}
5
+ ._1q511b66{padding-block-start:var(--ds-space-050,4px)}
4
6
  ._4cvr1h6o{align-items:center}
5
7
  ._yv0e1xuv{grid-template-columns:182px minmax(0,1fr)}
6
8
  ._yv0ehpfy{grid-template-columns:minmax(0,1fr) auto}
@@ -29,6 +29,12 @@ const headerContentStyles = null;
29
29
  const headerSearchStyles = null;
30
30
  const resultsId = 'registry-element-browser-results';
31
31
  const modalTestId = 'registry-element-browser-modal';
32
+ const getRenderedColumnCount = options => {
33
+ var _options$;
34
+ const firstRowTop = (_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.getBoundingClientRect().top;
35
+ const nextRowIndex = options.findIndex(option => firstRowTop !== undefined && option.getBoundingClientRect().top > firstRowTop + 1);
36
+ return nextRowIndex > 0 ? nextRowIndex : options.length;
37
+ };
32
38
  export const RegistryElementBrowser = ({
33
39
  components,
34
40
  emptyStateHandler,
@@ -58,6 +64,7 @@ export const RegistryElementBrowser = ({
58
64
  const [section, setSection] = useState(() => getInitialRegistryElementBrowserSection(model, defaultSection));
59
65
  const [selectedKey, setSelectedKey] = useState();
60
66
  const searchInputRef = useRef(null);
67
+ const selectedCategoryRef = useRef(null);
61
68
  const wasOpen = useRef(false);
62
69
  const previousIsOffline = useRef(isOffline);
63
70
  useEffect(() => {
@@ -111,16 +118,38 @@ export const RegistryElementBrowser = ({
111
118
  scrollableBody === null || scrollableBody === void 0 ? void 0 : scrollableBody.style.setProperty('border-block-end', 'none');
112
119
  }, []);
113
120
  const onKeyDown = useCallback(event => {
114
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
121
+ if (event.key === 'Tab' && event.shiftKey && event.target instanceof HTMLElement && event.target.getAttribute('role') === 'option') {
122
+ var _selectedCategoryRef$;
123
+ event.preventDefault();
124
+ (_selectedCategoryRef$ = selectedCategoryRef.current) === null || _selectedCategoryRef$ === void 0 ? void 0 : _selectedCategoryRef$.focus();
125
+ return;
126
+ }
127
+ if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
115
128
  var _resultCollection$que;
129
+ if (event.currentTarget === searchInputRef.current && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
130
+ return;
131
+ }
116
132
  const resultCollection = event.currentTarget.ownerDocument.getElementById(resultsId);
117
- const options = Array.from((_resultCollection$que = resultCollection === null || resultCollection === void 0 ? void 0 : resultCollection.querySelectorAll('[role="option"]:not([aria-disabled="true"]):not([disabled])')) !== null && _resultCollection$que !== void 0 ? _resultCollection$que : []);
133
+ const options = Array.from((_resultCollection$que = resultCollection === null || resultCollection === void 0 ? void 0 : resultCollection.querySelectorAll('[role="option"]')) !== null && _resultCollection$que !== void 0 ? _resultCollection$que : []);
118
134
  const currentIndex = options.findIndex(option => option === event.currentTarget.ownerDocument.activeElement);
119
- const nextIndex = event.key === 'ArrowDown' ? currentIndex + 1 : currentIndex - 1;
120
- const nextOption = options.at(nextIndex);
135
+ const columnCount = getRenderedColumnCount(options);
136
+ const step = event.key === 'ArrowDown' ? columnCount : event.key === 'ArrowUp' ? -columnCount : event.key === 'ArrowRight' ? 1 : -1;
137
+ let nextIndex = currentIndex < 0 ? 0 : currentIndex + step;
138
+ if (event.key === 'ArrowDown' && columnCount < options.length) {
139
+ nextIndex = Math.min(nextIndex, options.length - 1);
140
+ }
141
+ while (nextIndex >= 0 && nextIndex < options.length && (options[nextIndex].hasAttribute('disabled') || options[nextIndex].getAttribute('aria-disabled') === 'true')) {
142
+ nextIndex += step;
143
+ }
144
+ const nextOption = options[nextIndex];
121
145
  if (nextOption) {
122
146
  event.preventDefault();
123
147
  nextOption.focus();
148
+ nextOption.click();
149
+ } else if (nextIndex < 0 && currentIndex >= 0) {
150
+ var _searchInputRef$curre;
151
+ event.preventDefault();
152
+ (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 ? void 0 : _searchInputRef$curre.focus();
124
153
  }
125
154
  return;
126
155
  }
@@ -129,9 +158,18 @@ export const RegistryElementBrowser = ({
129
158
  onClose();
130
159
  return;
131
160
  }
132
- if (event.key === 'Enter' && selectedKey) {
133
- event.preventDefault();
134
- onConfirmInsert();
161
+ if (event.key === 'Enter') {
162
+ var _event$currentTarget$;
163
+ const focusedOption = event.target instanceof HTMLElement ? event.target.closest('[role="option"]') : null;
164
+ const firstOption = (_event$currentTarget$ = event.currentTarget.ownerDocument.getElementById(resultsId)) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.querySelector('[role="option"]:not([aria-disabled="true"]):not([disabled])');
165
+ const optionToActivate = focusedOption !== null && focusedOption !== void 0 ? focusedOption : firstOption;
166
+ if (selectedKey || optionToActivate) {
167
+ event.preventDefault();
168
+ if (!selectedKey) {
169
+ optionToActivate === null || optionToActivate === void 0 ? void 0 : optionToActivate.click();
170
+ }
171
+ onConfirmInsert();
172
+ }
135
173
  }
136
174
  }, [onClose, onConfirmInsert, selectedKey]);
137
175
  return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(Modal, {
@@ -177,11 +215,12 @@ export const RegistryElementBrowser = ({
177
215
  onClick: onClose,
178
216
  spacing: "compact"
179
217
  })))), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement("div", {
180
- className: ax(["_zulp1fka _1e0c11p5 _yv0e1xuv _lk4ji47z"])
218
+ className: ax(["_zulp1fka _18zr1b66 _1e0c11p5 _yv0e1xuv _1q511b66 _lk4ji47z"])
181
219
  }, /*#__PURE__*/React.createElement(RegistryElementBrowserCategories, {
182
220
  section: section,
183
221
  sections: model.sections,
184
- onSectionClick: onSectionClick
222
+ onSectionClick: onSectionClick,
223
+ selectedButtonRef: selectedCategoryRef
185
224
  }), /*#__PURE__*/React.createElement(RegistryElementBrowserSearchResults, {
186
225
  editorView: editorView,
187
226
  emptyStateHandler: emptyStateHandler,
@@ -1,7 +1,10 @@
1
- ._zulpu2gc{gap:var(--ds-space-100,8px)}._154iv77o{top:var(--ds-space-025,2px)}
1
+ ._zulpu2gc{gap:var(--ds-space-100,8px)}
2
+ ._18zr1b66{padding-inline:var(--ds-space-050,4px)}
3
+ ._1rjc1b66{padding-block:var(--ds-space-050,4px)}._154iidpf{top:0}
2
4
  ._1e0c11p5{display:grid}
5
+ ._1ul9idpf{min-width:0}
3
6
  ._1wpzv2br{align-self:start}
4
7
  ._ae4vv2br{align-content:start}
5
8
  ._kqsw1if8{position:sticky}
6
9
  ._yv0ei47z{grid-template-columns:minmax(0,1fr)}
7
- @media (max-width:599px){._qs0g1bhr{background-color:var(--ds-surface-overlay,#fff)}._1w2e1ris{grid-auto-columns:max-content}._1ato1bp4{grid-auto-flow:column}._lk4jglyw{grid-template-columns:none}._1cgyi47z{grid-template-rows:minmax(0,1fr)}._1s8e1wug{overflow-x:auto}._pevy15vq{overflow-y:hidden}._zvu9kb7n{z-index:1}}
10
+ @media (max-width:599px){._qs0g1bhr{background-color:var(--ds-surface-overlay,#fff)}._1w2e1ris{grid-auto-columns:max-content}._1ato1bp4{grid-auto-flow:column}._lk4jglyw{grid-template-columns:none}._1cgyi47z{grid-template-rows:minmax(0,1fr)}._1s8e1wug{overflow-x:auto}._pevy15vq{overflow-y:hidden}._dl261osq{width:100%}._zvu9kb7n{z-index:1}}
@@ -1,7 +1,7 @@
1
1
  /* RegistryElementBrowserCategories.tsx generated by @compiled/babel-plugin v3.0.2 */
2
2
  import "./RegistryElementBrowserCategories.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
- import React from 'react';
4
+ import React, { useCallback } from 'react';
5
5
  import { useIntl } from 'react-intl';
6
6
  import Button from '@atlaskit/button/default/button';
7
7
  import { BLOCK_TEMPLATES_SECTION, DATA_AND_CHARTS_SECTION, EMBED_SECTION, MEDIA_SECTION, OTHER_SECTION, ROVO_SECTION, STRUCTURE_SECTION, TEXT_FORMATTING_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
@@ -21,26 +21,44 @@ const categoryGridStyles = null;
21
21
  export const RegistryElementBrowserCategories = ({
22
22
  section,
23
23
  sections,
24
- onSectionClick
24
+ onSectionClick,
25
+ selectedButtonRef
25
26
  }) => {
26
27
  const {
27
28
  formatMessage
28
29
  } = useIntl();
29
30
  const isAllSelected = section === undefined;
31
+ const onCategoryKeyDown = useCallback(event => {
32
+ var _event$currentTarget$, _event$currentTarget$2, _event$currentTarget$3, _event$currentTarget$4;
33
+ if (!['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
34
+ return;
35
+ }
36
+ const isForward = event.key === 'ArrowDown' || event.key === 'ArrowRight';
37
+ const nextButton = isForward ? (_event$currentTarget$ = event.currentTarget.nextElementSibling) !== null && _event$currentTarget$ !== void 0 ? _event$currentTarget$ : (_event$currentTarget$2 = event.currentTarget.parentElement) === null || _event$currentTarget$2 === void 0 ? void 0 : _event$currentTarget$2.firstElementChild : (_event$currentTarget$3 = event.currentTarget.previousElementSibling) !== null && _event$currentTarget$3 !== void 0 ? _event$currentTarget$3 : (_event$currentTarget$4 = event.currentTarget.parentElement) === null || _event$currentTarget$4 === void 0 ? void 0 : _event$currentTarget$4.lastElementChild;
38
+ if (nextButton) {
39
+ event.preventDefault();
40
+ nextButton.focus();
41
+ nextButton.click();
42
+ }
43
+ }, []);
30
44
  return /*#__PURE__*/React.createElement("div", {
31
45
  "aria-label": formatMessage({
32
46
  defaultMessage: 'Element categories',
33
47
  id: 'editor.quick-insert.categories-label'
34
48
  }),
35
49
  "data-testid": "registry-element-browser-categories",
36
- className: ax(["_zulpu2gc _ae4vv2br _1wpzv2br _1e0c11p5 _yv0ei47z _kqsw1if8 _154iv77o _qs0g1bhr _1w2e1ris _1ato1bp4 _lk4jglyw _1cgyi47z _1s8e1wug _pevy15vq _zvu9kb7n"])
50
+ role: "group",
51
+ className: ax(["_zulpu2gc _1rjc1b66 _18zr1b66 _ae4vv2br _1wpzv2br _1e0c11p5 _yv0ei47z _1ul9idpf _kqsw1if8 _154iidpf _qs0g1bhr _1w2e1ris _1ato1bp4 _lk4jglyw _1cgyi47z _1s8e1wug _pevy15vq _dl261osq _zvu9kb7n"])
37
52
  }, /*#__PURE__*/React.createElement(Button, {
38
53
  appearance: 'subtle',
39
54
  "aria-pressed": isAllSelected,
40
55
  "data-section": "",
41
56
  onClick: onSectionClick,
57
+ onKeyDown: onCategoryKeyDown,
58
+ ref: isAllSelected ? selectedButtonRef : undefined,
42
59
  isSelected: isAllSelected,
43
- shouldFitContainer: true
60
+ shouldFitContainer: true,
61
+ tabIndex: isAllSelected ? 0 : -1
44
62
  }, /*#__PURE__*/React.createElement(Text, {
45
63
  align: "start",
46
64
  color: "inherit",
@@ -57,8 +75,11 @@ export const RegistryElementBrowserCategories = ({
57
75
  "data-section": entry.key,
58
76
  key: entry.key,
59
77
  onClick: onSectionClick,
78
+ onKeyDown: onCategoryKeyDown,
79
+ ref: section === entry.key ? selectedButtonRef : undefined,
60
80
  isSelected: section === entry.key,
61
- shouldFitContainer: true
81
+ shouldFitContainer: true,
82
+ tabIndex: section === entry.key ? 0 : -1
62
83
  }, /*#__PURE__*/React.createElement(Text, {
63
84
  align: "start",
64
85
  color: "inherit",
@@ -71,7 +71,7 @@ export const RegistryElementBrowserSearchResults = ({
71
71
  defaultMessage: 'Element results',
72
72
  id: 'editor.quick-insert.results-label'
73
73
  });
74
- const displayedItems = hasFallbackItems ? fallbackItems !== null && fallbackItems !== void 0 ? fallbackItems : [] : items;
74
+ const displayedItems = hasFallbackItems && fallbackItems ? fallbackItems : items;
75
75
  const shouldRenderEmptyState = items.length === 0 && !isLoading;
76
76
  const emptyState = shouldRenderEmptyState ? (_emptyStateHandler = emptyStateHandler === null || emptyStateHandler === void 0 ? void 0 : emptyStateHandler({
77
77
  mode: 'full',
@@ -108,9 +108,15 @@ export const RegistryElementBrowserSearchResults = ({
108
108
  tabIndex: -1
109
109
  }, displayedItems.length > 0 && /*#__PURE__*/React.createElement("div", {
110
110
  "aria-label": resultsLabel,
111
+ onFocus: event => {
112
+ if (event.target === event.currentTarget) {
113
+ var _event$currentTarget$;
114
+ (_event$currentTarget$ = event.currentTarget.querySelector('[role="option"]:not([aria-disabled="true"]):not([disabled])')) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.focus();
115
+ }
116
+ },
111
117
  onKeyDown: onKeyDown,
112
118
  role: "listbox",
113
- tabIndex: -1,
119
+ tabIndex: 0,
114
120
  className: ax(["_zulpu2gc _ae4vv2br _4cvrv2br _1e0c11p5 _yv0ei47z _16409sye _g98o1koq"])
115
121
  }, displayedItems.map(item => /*#__PURE__*/React.createElement(RegistryElementBrowserItem, {
116
122
  editorView: editorView,
@@ -1,6 +1,8 @@
1
1
  ._zulp1ejb{gap:var(--ds-space-300,24px)}
2
- ._zulp1fka{gap:calc(var(--ds-space-200, 1pc) + var(--ds-space-150, 9pt))}._1bsb1osq{width:100%}
2
+ ._zulp1fka{gap:calc(var(--ds-space-200, 1pc) + var(--ds-space-150, 9pt))}._18zr1b66{padding-inline:var(--ds-space-050,4px)}
3
+ ._1bsb1osq{width:100%}
3
4
  ._1e0c11p5{display:grid}
5
+ ._1q511b66{padding-block-start:var(--ds-space-050,4px)}
4
6
  ._4cvr1h6o{align-items:center}
5
7
  ._yv0e1xuv{grid-template-columns:182px minmax(0,1fr)}
6
8
  ._yv0ehpfy{grid-template-columns:minmax(0,1fr) auto}
@@ -30,6 +30,14 @@ var headerContentStyles = null;
30
30
  var headerSearchStyles = null;
31
31
  var resultsId = 'registry-element-browser-results';
32
32
  var modalTestId = 'registry-element-browser-modal';
33
+ var getRenderedColumnCount = function getRenderedColumnCount(options) {
34
+ var _options$;
35
+ var firstRowTop = (_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.getBoundingClientRect().top;
36
+ var nextRowIndex = options.findIndex(function (option) {
37
+ return firstRowTop !== undefined && option.getBoundingClientRect().top > firstRowTop + 1;
38
+ });
39
+ return nextRowIndex > 0 ? nextRowIndex : options.length;
40
+ };
33
41
  export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
34
42
  var _model$fallbackItems$, _model$fallbackItems;
35
43
  var components = _ref.components,
@@ -75,6 +83,7 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
75
83
  selectedKey = _useState6[0],
76
84
  setSelectedKey = _useState6[1];
77
85
  var searchInputRef = useRef(null);
86
+ var selectedCategoryRef = useRef(null);
78
87
  var wasOpen = useRef(false);
79
88
  var previousIsOffline = useRef(isOffline);
80
89
  useEffect(function () {
@@ -130,18 +139,40 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
130
139
  scrollableBody === null || scrollableBody === void 0 || scrollableBody.style.setProperty('border-block-end', 'none');
131
140
  }, []);
132
141
  var onKeyDown = useCallback(function (event) {
133
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
142
+ if (event.key === 'Tab' && event.shiftKey && event.target instanceof HTMLElement && event.target.getAttribute('role') === 'option') {
143
+ var _selectedCategoryRef$;
144
+ event.preventDefault();
145
+ (_selectedCategoryRef$ = selectedCategoryRef.current) === null || _selectedCategoryRef$ === void 0 || _selectedCategoryRef$.focus();
146
+ return;
147
+ }
148
+ if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
134
149
  var _resultCollection$que;
150
+ if (event.currentTarget === searchInputRef.current && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
151
+ return;
152
+ }
135
153
  var resultCollection = event.currentTarget.ownerDocument.getElementById(resultsId);
136
- var options = Array.from((_resultCollection$que = resultCollection === null || resultCollection === void 0 ? void 0 : resultCollection.querySelectorAll('[role="option"]:not([aria-disabled="true"]):not([disabled])')) !== null && _resultCollection$que !== void 0 ? _resultCollection$que : []);
154
+ var options = Array.from((_resultCollection$que = resultCollection === null || resultCollection === void 0 ? void 0 : resultCollection.querySelectorAll('[role="option"]')) !== null && _resultCollection$que !== void 0 ? _resultCollection$que : []);
137
155
  var currentIndex = options.findIndex(function (option) {
138
156
  return option === event.currentTarget.ownerDocument.activeElement;
139
157
  });
140
- var nextIndex = event.key === 'ArrowDown' ? currentIndex + 1 : currentIndex - 1;
141
- var nextOption = options.at(nextIndex);
158
+ var columnCount = getRenderedColumnCount(options);
159
+ var step = event.key === 'ArrowDown' ? columnCount : event.key === 'ArrowUp' ? -columnCount : event.key === 'ArrowRight' ? 1 : -1;
160
+ var nextIndex = currentIndex < 0 ? 0 : currentIndex + step;
161
+ if (event.key === 'ArrowDown' && columnCount < options.length) {
162
+ nextIndex = Math.min(nextIndex, options.length - 1);
163
+ }
164
+ while (nextIndex >= 0 && nextIndex < options.length && (options[nextIndex].hasAttribute('disabled') || options[nextIndex].getAttribute('aria-disabled') === 'true')) {
165
+ nextIndex += step;
166
+ }
167
+ var nextOption = options[nextIndex];
142
168
  if (nextOption) {
143
169
  event.preventDefault();
144
170
  nextOption.focus();
171
+ nextOption.click();
172
+ } else if (nextIndex < 0 && currentIndex >= 0) {
173
+ var _searchInputRef$curre;
174
+ event.preventDefault();
175
+ (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 || _searchInputRef$curre.focus();
145
176
  }
146
177
  return;
147
178
  }
@@ -150,9 +181,18 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
150
181
  onClose();
151
182
  return;
152
183
  }
153
- if (event.key === 'Enter' && selectedKey) {
154
- event.preventDefault();
155
- onConfirmInsert();
184
+ if (event.key === 'Enter') {
185
+ var _event$currentTarget$;
186
+ var focusedOption = event.target instanceof HTMLElement ? event.target.closest('[role="option"]') : null;
187
+ var firstOption = (_event$currentTarget$ = event.currentTarget.ownerDocument.getElementById(resultsId)) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.querySelector('[role="option"]:not([aria-disabled="true"]):not([disabled])');
188
+ var optionToActivate = focusedOption !== null && focusedOption !== void 0 ? focusedOption : firstOption;
189
+ if (selectedKey || optionToActivate) {
190
+ event.preventDefault();
191
+ if (!selectedKey) {
192
+ optionToActivate === null || optionToActivate === void 0 || optionToActivate.click();
193
+ }
194
+ onConfirmInsert();
195
+ }
156
196
  }
157
197
  }, [onClose, onConfirmInsert, selectedKey]);
158
198
  return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(Modal, {
@@ -198,11 +238,12 @@ export var RegistryElementBrowser = function RegistryElementBrowser(_ref) {
198
238
  onClick: onClose,
199
239
  spacing: "compact"
200
240
  })))), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement("div", {
201
- className: ax(["_zulp1fka _1e0c11p5 _yv0e1xuv _lk4ji47z"])
241
+ className: ax(["_zulp1fka _18zr1b66 _1e0c11p5 _yv0e1xuv _1q511b66 _lk4ji47z"])
202
242
  }, /*#__PURE__*/React.createElement(RegistryElementBrowserCategories, {
203
243
  section: section,
204
244
  sections: model.sections,
205
- onSectionClick: onSectionClick
245
+ onSectionClick: onSectionClick,
246
+ selectedButtonRef: selectedCategoryRef
206
247
  }), /*#__PURE__*/React.createElement(RegistryElementBrowserSearchResults, {
207
248
  editorView: editorView,
208
249
  emptyStateHandler: emptyStateHandler,
@@ -1,7 +1,10 @@
1
- ._zulpu2gc{gap:var(--ds-space-100,8px)}._154iv77o{top:var(--ds-space-025,2px)}
1
+ ._zulpu2gc{gap:var(--ds-space-100,8px)}
2
+ ._18zr1b66{padding-inline:var(--ds-space-050,4px)}
3
+ ._1rjc1b66{padding-block:var(--ds-space-050,4px)}._154iidpf{top:0}
2
4
  ._1e0c11p5{display:grid}
5
+ ._1ul9idpf{min-width:0}
3
6
  ._1wpzv2br{align-self:start}
4
7
  ._ae4vv2br{align-content:start}
5
8
  ._kqsw1if8{position:sticky}
6
9
  ._yv0ei47z{grid-template-columns:minmax(0,1fr)}
7
- @media (max-width:599px){._qs0g1bhr{background-color:var(--ds-surface-overlay,#fff)}._1w2e1ris{grid-auto-columns:max-content}._1ato1bp4{grid-auto-flow:column}._lk4jglyw{grid-template-columns:none}._1cgyi47z{grid-template-rows:minmax(0,1fr)}._1s8e1wug{overflow-x:auto}._pevy15vq{overflow-y:hidden}._zvu9kb7n{z-index:1}}
10
+ @media (max-width:599px){._qs0g1bhr{background-color:var(--ds-surface-overlay,#fff)}._1w2e1ris{grid-auto-columns:max-content}._1ato1bp4{grid-auto-flow:column}._lk4jglyw{grid-template-columns:none}._1cgyi47z{grid-template-rows:minmax(0,1fr)}._1s8e1wug{overflow-x:auto}._pevy15vq{overflow-y:hidden}._dl261osq{width:100%}._zvu9kb7n{z-index:1}}
@@ -2,7 +2,7 @@
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import "./RegistryElementBrowserCategories.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
- import React from 'react';
5
+ import React, { useCallback } from 'react';
6
6
  import { useIntl } from 'react-intl';
7
7
  import Button from '@atlaskit/button/default/button';
8
8
  import { BLOCK_TEMPLATES_SECTION, DATA_AND_CHARTS_SECTION, EMBED_SECTION, MEDIA_SECTION, OTHER_SECTION, ROVO_SECTION, STRUCTURE_SECTION, TEXT_FORMATTING_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
@@ -13,24 +13,42 @@ var categoryGridStyles = null;
13
13
  export var RegistryElementBrowserCategories = function RegistryElementBrowserCategories(_ref) {
14
14
  var section = _ref.section,
15
15
  sections = _ref.sections,
16
- onSectionClick = _ref.onSectionClick;
16
+ onSectionClick = _ref.onSectionClick,
17
+ selectedButtonRef = _ref.selectedButtonRef;
17
18
  var _useIntl = useIntl(),
18
19
  formatMessage = _useIntl.formatMessage;
19
20
  var isAllSelected = section === undefined;
21
+ var onCategoryKeyDown = useCallback(function (event) {
22
+ var _event$currentTarget$, _event$currentTarget$2, _event$currentTarget$3, _event$currentTarget$4;
23
+ if (!['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
24
+ return;
25
+ }
26
+ var isForward = event.key === 'ArrowDown' || event.key === 'ArrowRight';
27
+ var nextButton = isForward ? (_event$currentTarget$ = event.currentTarget.nextElementSibling) !== null && _event$currentTarget$ !== void 0 ? _event$currentTarget$ : (_event$currentTarget$2 = event.currentTarget.parentElement) === null || _event$currentTarget$2 === void 0 ? void 0 : _event$currentTarget$2.firstElementChild : (_event$currentTarget$3 = event.currentTarget.previousElementSibling) !== null && _event$currentTarget$3 !== void 0 ? _event$currentTarget$3 : (_event$currentTarget$4 = event.currentTarget.parentElement) === null || _event$currentTarget$4 === void 0 ? void 0 : _event$currentTarget$4.lastElementChild;
28
+ if (nextButton) {
29
+ event.preventDefault();
30
+ nextButton.focus();
31
+ nextButton.click();
32
+ }
33
+ }, []);
20
34
  return /*#__PURE__*/React.createElement("div", {
21
35
  "aria-label": formatMessage({
22
36
  defaultMessage: 'Element categories',
23
37
  id: 'editor.quick-insert.categories-label'
24
38
  }),
25
39
  "data-testid": "registry-element-browser-categories",
26
- className: ax(["_zulpu2gc _ae4vv2br _1wpzv2br _1e0c11p5 _yv0ei47z _kqsw1if8 _154iv77o _qs0g1bhr _1w2e1ris _1ato1bp4 _lk4jglyw _1cgyi47z _1s8e1wug _pevy15vq _zvu9kb7n"])
40
+ role: "group",
41
+ className: ax(["_zulpu2gc _1rjc1b66 _18zr1b66 _ae4vv2br _1wpzv2br _1e0c11p5 _yv0ei47z _1ul9idpf _kqsw1if8 _154iidpf _qs0g1bhr _1w2e1ris _1ato1bp4 _lk4jglyw _1cgyi47z _1s8e1wug _pevy15vq _dl261osq _zvu9kb7n"])
27
42
  }, /*#__PURE__*/React.createElement(Button, {
28
43
  appearance: 'subtle',
29
44
  "aria-pressed": isAllSelected,
30
45
  "data-section": "",
31
46
  onClick: onSectionClick,
47
+ onKeyDown: onCategoryKeyDown,
48
+ ref: isAllSelected ? selectedButtonRef : undefined,
32
49
  isSelected: isAllSelected,
33
- shouldFitContainer: true
50
+ shouldFitContainer: true,
51
+ tabIndex: isAllSelected ? 0 : -1
34
52
  }, /*#__PURE__*/React.createElement(Text, {
35
53
  align: "start",
36
54
  color: "inherit",
@@ -47,8 +65,11 @@ export var RegistryElementBrowserCategories = function RegistryElementBrowserCat
47
65
  "data-section": entry.key,
48
66
  key: entry.key,
49
67
  onClick: onSectionClick,
68
+ onKeyDown: onCategoryKeyDown,
69
+ ref: section === entry.key ? selectedButtonRef : undefined,
50
70
  isSelected: section === entry.key,
51
- shouldFitContainer: true
71
+ shouldFitContainer: true,
72
+ tabIndex: section === entry.key ? 0 : -1
52
73
  }, /*#__PURE__*/React.createElement(Text, {
53
74
  align: "start",
54
75
  color: "inherit",
@@ -75,7 +75,7 @@ export var RegistryElementBrowserSearchResults = function RegistryElementBrowser
75
75
  defaultMessage: 'Element results',
76
76
  id: 'editor.quick-insert.results-label'
77
77
  });
78
- var displayedItems = hasFallbackItems ? fallbackItems !== null && fallbackItems !== void 0 ? fallbackItems : [] : items;
78
+ var displayedItems = hasFallbackItems && fallbackItems ? fallbackItems : items;
79
79
  var shouldRenderEmptyState = items.length === 0 && !isLoading;
80
80
  var emptyState = shouldRenderEmptyState ? (_emptyStateHandler = emptyStateHandler === null || emptyStateHandler === void 0 ? void 0 : emptyStateHandler(_objectSpread({
81
81
  mode: 'full',
@@ -111,9 +111,15 @@ export var RegistryElementBrowserSearchResults = function RegistryElementBrowser
111
111
  tabIndex: -1
112
112
  }, displayedItems.length > 0 && /*#__PURE__*/React.createElement("div", {
113
113
  "aria-label": resultsLabel,
114
+ onFocus: function onFocus(event) {
115
+ if (event.target === event.currentTarget) {
116
+ var _event$currentTarget$;
117
+ (_event$currentTarget$ = event.currentTarget.querySelector('[role="option"]:not([aria-disabled="true"]):not([disabled])')) === null || _event$currentTarget$ === void 0 || _event$currentTarget$.focus();
118
+ }
119
+ },
114
120
  onKeyDown: onKeyDown,
115
121
  role: "listbox",
116
- tabIndex: -1,
122
+ tabIndex: 0,
117
123
  className: ax(["_zulpu2gc _ae4vv2br _4cvrv2br _1e0c11p5 _yv0ei47z _16409sye _g98o1koq"])
118
124
  }, displayedItems.map(function (item) {
119
125
  return /*#__PURE__*/React.createElement(RegistryElementBrowserItem, {
@@ -8,6 +8,7 @@ type Props = {
8
8
  onSectionClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
9
9
  section?: string;
10
10
  sections: RegistryElementBrowserSection[];
11
+ selectedButtonRef: React.Ref<HTMLButtonElement>;
11
12
  };
12
- export declare const RegistryElementBrowserCategories: ({ section, sections, onSectionClick, }: Props) => React.JSX.Element;
13
+ export declare const RegistryElementBrowserCategories: ({ section, sections, onSectionClick, selectedButtonRef, }: Props) => React.JSX.Element;
13
14
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-quick-insert",
3
- "version": "22.0.9",
3
+ "version": "22.0.10",
4
4
  "description": "Quick insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",