@react-aria/selection 3.13.1 → 3.15.0
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/dist/import.mjs +80 -21
- package/dist/main.js +79 -20
- package/dist/main.js.map +1 -1
- package/dist/module.js +80 -21
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +13 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/ListKeyboardDelegate.ts +101 -17
- package/src/useSelectableCollection.ts +9 -1
- package/src/useSelectableItem.ts +5 -2
- package/src/useTypeSelect.ts +1 -1
package/src/useSelectableItem.ts
CHANGED
|
@@ -67,6 +67,8 @@ export interface SelectableItemStates {
|
|
|
67
67
|
isPressed: boolean,
|
|
68
68
|
/** Whether the item is currently selected. */
|
|
69
69
|
isSelected: boolean,
|
|
70
|
+
/** Whether the item is currently focused. */
|
|
71
|
+
isFocused: boolean,
|
|
70
72
|
/**
|
|
71
73
|
* Whether the item is non-interactive, i.e. both selection and actions are disabled and the item may
|
|
72
74
|
* not be focused. Dependent on `disabledKeys` and `disabledBehavior`.
|
|
@@ -137,10 +139,10 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
|
|
|
137
139
|
// Focus the associated DOM node when this item becomes the focusedKey
|
|
138
140
|
useEffect(() => {
|
|
139
141
|
let isFocused = key === manager.focusedKey;
|
|
140
|
-
if (isFocused && manager.isFocused && !shouldUseVirtualFocus
|
|
142
|
+
if (isFocused && manager.isFocused && !shouldUseVirtualFocus) {
|
|
141
143
|
if (focus) {
|
|
142
144
|
focus();
|
|
143
|
-
} else {
|
|
145
|
+
} else if (document.activeElement !== ref.current) {
|
|
144
146
|
focusSafely(ref.current);
|
|
145
147
|
}
|
|
146
148
|
}
|
|
@@ -312,6 +314,7 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
|
|
|
312
314
|
),
|
|
313
315
|
isPressed,
|
|
314
316
|
isSelected: manager.isSelected(key),
|
|
317
|
+
isFocused: manager.isFocused && manager.focusedKey === key,
|
|
315
318
|
isDisabled,
|
|
316
319
|
allowsSelection,
|
|
317
320
|
hasAction
|
package/src/useTypeSelect.ts
CHANGED
|
@@ -53,7 +53,7 @@ export function useTypeSelect(options: AriaTypeSelectOptions): TypeSelectAria {
|
|
|
53
53
|
|
|
54
54
|
let onKeyDown = (e: KeyboardEvent) => {
|
|
55
55
|
let character = getStringForKey(e.key);
|
|
56
|
-
if (!character || e.ctrlKey || e.metaKey) {
|
|
56
|
+
if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target as HTMLElement)) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
|