@rh-support/components 2.6.33 → 2.6.35

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.
@@ -13,9 +13,5 @@ export declare function useSelectKeyboardNavigator({ list, isOpen, ignoreResetOn
13
13
  onInputKeyDown: (event: any) => void;
14
14
  setFocusedItemIndex: React.Dispatch<React.SetStateAction<number>>;
15
15
  };
16
- export declare function useSelectKeyboardNavigatorModified({ list, isOpen, setIsOpen, onSelect }: IProps): {
17
- onInputKeyDown: (event: any) => void;
18
- focusedItemIndex: number;
19
- };
20
16
  export {};
21
17
  //# sourceMappingURL=useSelectKeyboardNavigator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectKeyboardNavigator.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSelectKeyboardNavigator.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,UAAU,MAAM;IACZ,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAC1D,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,0BAA0B,CAAC,EACvC,IAAI,EACJ,MAAM,EACN,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,QAAQ,GACX,EAAE,MAAM;;;;EAqFR;AAED,wBAAgB,kCAAkC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM;;;EAqD/F"}
1
+ {"version":3,"file":"useSelectKeyboardNavigator.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSelectKeyboardNavigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,UAAU,MAAM;IACZ,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAC1D,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,0BAA0B,CAAC,EACvC,IAAI,EACJ,MAAM,EACN,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,QAAQ,GACX,EAAE,MAAM;;;;EAyFR"}
@@ -1,4 +1,3 @@
1
- import { haltEvent } from '@rh-support/utils';
2
1
  import { useEffect, useState } from 'react';
3
2
  export function useSelectKeyboardNavigator({ list, isOpen, ignoreResetOnListChange, resetIndexOnClose, isDisabled, setIsOpen, onSelect, }) {
4
3
  const [focusedItemIndex, setFocusedItemIndex] = useState(null);
@@ -27,6 +26,9 @@ export function useSelectKeyboardNavigator({ list, isOpen, ignoreResetOnListChan
27
26
  const handleMenuArrowKeys = (key) => {
28
27
  let indexToFocus;
29
28
  if (isOpen) {
29
+ if (list.length === 0) {
30
+ return;
31
+ }
30
32
  if (key === 'ArrowUp') {
31
33
  // When no index is set or at the first index, focus to the last, otherwise decrement focus index
32
34
  if (focusedItemIndex === null || focusedItemIndex === 0) {
@@ -62,7 +64,7 @@ export function useSelectKeyboardNavigator({ list, isOpen, ignoreResetOnListChan
62
64
  if (!isOpen && !isDisabled) {
63
65
  setIsOpen((pre) => !pre);
64
66
  }
65
- else if (isOpen && focusedItem !== null) {
67
+ else if (isOpen && focusedItem) {
66
68
  onSelect(focusedItem);
67
69
  }
68
70
  break;
@@ -79,55 +81,3 @@ export function useSelectKeyboardNavigator({ list, isOpen, ignoreResetOnListChan
79
81
  };
80
82
  return { focusedItemIndex, onInputKeyDown, setFocusedItemIndex };
81
83
  }
82
- export function useSelectKeyboardNavigatorModified({ list, isOpen, setIsOpen, onSelect }) {
83
- const [focusedItemIndex, setFocusedItemIndex] = useState(0);
84
- const handleMenuArrowKeys = (key) => {
85
- if (isOpen) {
86
- setFocusedItemIndex((localIndex) => {
87
- let indexToFocus;
88
- if (key === 'ArrowUp') {
89
- // When no index is set or at the first index, focus to the last, otherwise decrement focus index
90
- if (localIndex === 0) {
91
- indexToFocus = list.length - 1;
92
- }
93
- else {
94
- indexToFocus = localIndex - 1;
95
- }
96
- }
97
- if (key === 'ArrowDown') {
98
- // When no index is set or at the last index, focus to the first, otherwise increment focus index
99
- if (localIndex === list.length - 1) {
100
- indexToFocus = 0;
101
- }
102
- else {
103
- indexToFocus = localIndex + 1;
104
- }
105
- }
106
- return indexToFocus;
107
- });
108
- }
109
- };
110
- const onInputKeyDown = (event) => {
111
- switch (event.key) {
112
- // Select the first available option
113
- case 'Enter':
114
- const focusedItem = focusedItemIndex !== null ? list[focusedItemIndex] : null;
115
- if (!isOpen) {
116
- setIsOpen((pre) => !pre);
117
- }
118
- else if (isOpen && focusedItem !== null) {
119
- onSelect(focusedItem);
120
- }
121
- break;
122
- case 'Escape':
123
- setIsOpen(false);
124
- break;
125
- case 'ArrowUp':
126
- case 'ArrowDown':
127
- haltEvent(event);
128
- handleMenuArrowKeys(event.key);
129
- break;
130
- }
131
- };
132
- return { onInputKeyDown, focusedItemIndex };
133
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/components",
3
- "version": "2.6.33",
3
+ "version": "2.6.35",
4
4
  "description": "Contains all reusabel components for support app",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -62,8 +62,8 @@
62
62
  "@patternfly/react-icons": "6.2.1",
63
63
  "@patternfly/react-table": "6.2.1",
64
64
  "@rh-support/types": "2.0.31",
65
- "@rh-support/user-permissions": "2.6.30",
66
- "@rh-support/utils": "2.6.29",
65
+ "@rh-support/user-permissions": "2.6.32",
66
+ "@rh-support/utils": "2.6.31",
67
67
  "dompurify": "^2.2.6",
68
68
  "js-worker-search": "^1.4.1",
69
69
  "lazysizes": "^5.3.2",
@@ -103,5 +103,5 @@
103
103
  "defaults and supports es6-module",
104
104
  "maintained node versions"
105
105
  ],
106
- "gitHead": "f99f57bcf4460ad269285c718193ecadca625389"
106
+ "gitHead": "8d375371c521c2b8e6df87bd8d395af7118a01b6"
107
107
  }