@@ -14,6 +14,7 @@ import {BaseCollection} from './BaseCollection';
14
14
import { BaseNode , Document , ElementNode } from './Document' ;
15
15
import { CachedChildrenOptions , useCachedChildren } from './useCachedChildren' ;
16
16
import { createPortal } from 'react-dom' ;
17
+ import { FocusableContext } from '@react-aria/interactions' ;
17
18
import { forwardRefType , Node } from '@react-types/shared' ;
18
19
import { Hidden } from './Hidden' ;
19
20
import React , { createContext , ForwardedRef , forwardRef , JSX , ReactElement , ReactNode , useCallback , useContext , useMemo , useRef , useState } from 'react' ;
@@ -161,6 +162,7 @@ export function createLeafComponent<T extends object, P extends object, E extend
161
162
export function createLeafComponent < P extends object , E extends Element > ( type : string , render : ( props : P , ref : ForwardedRef < E > , node ?: any ) => ReactElement ) {
162
163
let Component = ( { node} ) => render ( node . props , node . props . ref , node ) ;
163
164
let Result = ( forwardRef as forwardRefType ) ( ( props : P , ref : ForwardedRef < E > ) => {
165
+ let focusableProps = useContext ( FocusableContext ) ;
164
166
let isShallow = useContext ( ShallowRenderContext ) ;
165
167
if ( ! isShallow ) {
166
168
if ( render . length >= 3 ) {
@@ -169,7 +171,19 @@ export function createLeafComponent<P extends object, E extends Element>(type: s
169
171
return render ( props , ref ) ;
170
172
}
171
173
172
- return useSSRCollectionNode ( type , props , ref , 'children' in props ? props . children : null , null , node => < Component node = { node } /> ) ;
174
+ return useSSRCollectionNode (
175
+ type ,
176
+ props ,
177
+ ref ,
178
+ 'children' in props ? props . children : null ,
179
+ null ,
180
+ node => (
181
+ // Forward FocusableContext to real DOM tree so tooltips work.
182
+ < FocusableContext . Provider value = { focusableProps } >
183
+ < Component node = { node } />
184
+ </ FocusableContext . Provider >
185
+ )
186
+ ) ;
173
187
} ) ;
174
188
// @ts -ignore
175
189
Result . displayName = render . name ;
0 commit comments