1212
1313import { DOMAttributes , FocusableDOMProps , FocusableElement , FocusableProps } from '@react-types/shared' ;
1414import { focusSafely } from './' ;
15- import { mergeProps , useSyncRef } from '@react-aria/utils' ;
16- import React , { MutableRefObject , ReactNode , RefObject , useContext , useEffect , useRef } from 'react' ;
15+ import { mergeProps , useObjectRef , useSyncRef } from '@react-aria/utils' ;
16+ import React , { ForwardedRef , MutableRefObject , ReactNode , RefObject , useContext , useEffect , useRef } from 'react' ;
1717import { useFocus , useKeyboard } from '@react-aria/interactions' ;
1818
1919export interface FocusableOptions extends FocusableProps , FocusableDOMProps {
@@ -30,7 +30,7 @@ interface FocusableContextValue extends FocusableProviderProps {
3030 ref ?: MutableRefObject < FocusableElement >
3131}
3232
33- let FocusableContext = React . createContext < FocusableContextValue > ( null ) ;
33+ let FocusableContext = React . createContext < FocusableContextValue | null > ( null ) ;
3434
3535function useFocusableContext ( ref : RefObject < FocusableElement > ) : FocusableContextValue {
3636 let context = useContext ( FocusableContext ) || { } ;
@@ -44,11 +44,12 @@ function useFocusableContext(ref: RefObject<FocusableElement>): FocusableContext
4444/**
4545 * Provides DOM props to the nearest focusable child.
4646 */
47- function FocusableProvider ( props : FocusableProviderProps , ref : RefObject < FocusableElement > ) {
47+ function FocusableProvider ( props : FocusableProviderProps , ref : ForwardedRef < FocusableElement > ) {
4848 let { children, ...otherProps } = props ;
49+ let objRef = useObjectRef ( ref ) ;
4950 let context = {
5051 ...otherProps ,
51- ref
52+ ref : objRef
5253 } ;
5354
5455 return (
0 commit comments