@db-ux/react-core-components 3.1.15 → 3.1.16

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.
@@ -189,7 +189,7 @@ function DBCustomSelectFn(props, component) {
189
189
  }
190
190
  }
191
191
  function handleArrowDownUp(event) {
192
- var _a, _b, _c, _d, _e, _f, _g;
192
+ var _a, _b, _c;
193
193
  if ((_a = detailsRef.current) === null || _a === void 0 ? void 0 : _a.open) {
194
194
  if (self.document) {
195
195
  const activeElement = self.document.activeElement;
@@ -200,36 +200,53 @@ function DBCustomSelectFn(props, component) {
200
200
  if (isCheckbox) {
201
201
  const listElement = activeElement === null || activeElement === void 0 ? void 0 : activeElement.closest("li");
202
202
  if (event.key === "ArrowDown" || event.key === "ArrowRight") {
203
- if (listElement === null || listElement === void 0 ? void 0 : listElement.nextElementSibling) {
204
- (_c = (_b = listElement === null || listElement === void 0 ? void 0 : listElement.nextElementSibling) === null || _b === void 0 ? void 0 : _b.querySelector("input")) === null || _c === void 0 ? void 0 : _c.focus();
203
+ // Find next element with input, skipping group titles
204
+ let nextElement = listElement === null || listElement === void 0 ? void 0 : listElement.nextElementSibling;
205
+ while (nextElement) {
206
+ const nextInput = nextElement.querySelector("input");
207
+ if (nextInput) {
208
+ nextInput.focus();
209
+ break;
210
+ }
211
+ nextElement = nextElement.nextElementSibling;
205
212
  }
206
- else {
213
+ if (!nextElement) {
207
214
  // We are on the last checkbox we move to the top checkbox
208
215
  handleFocusFirstDropdownCheckbox(activeElement);
209
216
  }
210
217
  }
211
218
  else {
212
- if (listElement === null || listElement === void 0 ? void 0 : listElement.previousElementSibling) {
213
- (_e = (_d = listElement === null || listElement === void 0 ? void 0 : listElement.previousElementSibling) === null || _d === void 0 ? void 0 : _d.querySelector("input")) === null || _e === void 0 ? void 0 : _e.focus();
214
- }
215
- else if (detailsRef.current.querySelector(`input[type="checkbox"]`) !==
216
- activeElement) {
217
- // We are on the top list checkbox but there is a select all checkbox as well
218
- handleFocusFirstDropdownCheckbox(activeElement);
219
+ // Find previous element with input, skipping group titles
220
+ let prevElement = listElement === null || listElement === void 0 ? void 0 : listElement.previousElementSibling;
221
+ while (prevElement) {
222
+ const prevInput = prevElement.querySelector("input");
223
+ if (prevInput) {
224
+ prevInput.focus();
225
+ break;
226
+ }
227
+ prevElement = prevElement.previousElementSibling;
219
228
  }
220
- else {
221
- // We are on the top checkbox, we need to move to the search
222
- // or to the last checkbox
223
- const search = getSearchInput(detailsRef.current);
224
- if (search) {
225
- delay(() => {
226
- search.focus();
227
- }, 100);
229
+ if (!prevElement) {
230
+ // Check if we have a "select all" checkbox (only relevant for multi-select)
231
+ const selectAllCheckbox = detailsRef.current.querySelector(`input[type="checkbox"]`);
232
+ if (selectAllCheckbox && selectAllCheckbox !== activeElement) {
233
+ // We are on the top list checkbox but there is a select all checkbox as well
234
+ handleFocusFirstDropdownCheckbox(activeElement);
228
235
  }
229
236
  else {
230
- const checkboxList = Array.from((_f = detailsRef.current) === null || _f === void 0 ? void 0 : _f.querySelectorAll(`input[type="checkbox"],input[type="radio"]`));
231
- if (checkboxList.length) {
232
- (_g = checkboxList.at(-1)) === null || _g === void 0 ? void 0 : _g.focus();
237
+ // We are on the top checkbox, we need to move to the search
238
+ // or to the last checkbox
239
+ const search = getSearchInput(detailsRef.current);
240
+ if (search) {
241
+ delay(() => {
242
+ search.focus();
243
+ }, 100);
244
+ }
245
+ else {
246
+ const checkboxList = Array.from((_b = detailsRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(`input[type="checkbox"],input[type="radio"]`));
247
+ if (checkboxList.length) {
248
+ (_c = checkboxList.at(-1)) === null || _c === void 0 ? void 0 : _c.focus();
249
+ }
233
250
  }
234
251
  }
235
252
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/react-core-components",
3
- "version": "3.1.15",
3
+ "version": "3.1.16",
4
4
  "description": "React components for @db-ux/core-components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,8 @@
11
11
  "module": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [
14
- "dist/"
14
+ "dist/",
15
+ "CHANGELOG.md"
15
16
  ],
16
17
  "scripts": {
17
18
  "build": "npm-run-all tsc",
@@ -36,5 +37,9 @@
36
37
  "registry": "https://registry.npmjs.org/",
37
38
  "access": "public"
38
39
  },
39
- "sideEffects": false
40
+ "sideEffects": false,
41
+ "dependencies": {
42
+ "@db-ux/core-components": "3.1.16",
43
+ "@db-ux/core-foundations": "3.1.16"
44
+ }
40
45
  }