@react-aria/focus 3.5.2 → 3.5.5
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/main.js +168 -165
- package/dist/main.js.map +1 -1
- package/dist/module.js +164 -161
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +7 -265
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/FocusScope.tsx +1 -1
- package/src/useFocusable.tsx +9 -3
package/src/useFocusable.tsx
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {FocusableDOMProps, FocusableProps} from '@react-types/shared';
|
|
14
|
+
import {focusSafely} from './';
|
|
14
15
|
import {mergeProps, useSyncRef} from '@react-aria/utils';
|
|
15
16
|
import React, {HTMLAttributes, MutableRefObject, ReactNode, RefObject, useContext, useEffect, useRef} from 'react';
|
|
16
17
|
import {useFocus, useKeyboard} from '@react-aria/interactions';
|
|
@@ -60,10 +61,15 @@ function FocusableProvider(props: FocusableProviderProps, ref: RefObject<HTMLEle
|
|
|
60
61
|
let _FocusableProvider = React.forwardRef(FocusableProvider);
|
|
61
62
|
export {_FocusableProvider as FocusableProvider};
|
|
62
63
|
|
|
64
|
+
interface FocusableAria {
|
|
65
|
+
/** Props for the focusable element. */
|
|
66
|
+
focusableProps: HTMLAttributes<HTMLElement>
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
/**
|
|
64
70
|
* Used to make an element focusable and capable of auto focus.
|
|
65
71
|
*/
|
|
66
|
-
export function useFocusable(props: FocusableOptions, domRef: RefObject<HTMLElement>) {
|
|
72
|
+
export function useFocusable(props: FocusableOptions, domRef: RefObject<HTMLElement>): FocusableAria {
|
|
67
73
|
let {focusProps} = useFocus(props);
|
|
68
74
|
let {keyboardProps} = useKeyboard(props);
|
|
69
75
|
let interactions = mergeProps(focusProps, keyboardProps);
|
|
@@ -73,10 +79,10 @@ export function useFocusable(props: FocusableOptions, domRef: RefObject<HTMLElem
|
|
|
73
79
|
|
|
74
80
|
useEffect(() => {
|
|
75
81
|
if (autoFocusRef.current && domRef.current) {
|
|
76
|
-
domRef.current
|
|
82
|
+
focusSafely(domRef.current);
|
|
77
83
|
}
|
|
78
84
|
autoFocusRef.current = false;
|
|
79
|
-
}, []);
|
|
85
|
+
}, [domRef]);
|
|
80
86
|
|
|
81
87
|
return {
|
|
82
88
|
focusableProps: mergeProps(
|