@@ -7,50 +7,50 @@ import { useTabster } from './useTabster';
7
7
* Returns a set of helper functions that will traverse focusable elements in the context of a root DOM element
8
8
*/
9
9
export const useFocusFinders = ( ) => {
10
- const tabster = useTabster ( ) ;
10
+ const tabsterRef = useTabster ( ) ;
11
11
const { targetDocument } = useFluent ( ) ;
12
12
13
13
// Narrow props for now and let need dictate additional props in the future
14
14
const findAllFocusable = React . useCallback (
15
15
( container : HTMLElement , acceptCondition ?: ( el : HTMLElement ) => boolean ) =>
16
- tabster ?. focusable . findAll ( { container, acceptCondition } ) || [ ] ,
17
- [ tabster ] ,
16
+ tabsterRef . current ?. focusable . findAll ( { container, acceptCondition } ) || [ ] ,
17
+ [ tabsterRef ] ,
18
18
) ;
19
19
20
20
const findFirstFocusable = React . useCallback (
21
- ( container : HTMLElement ) => tabster ?. focusable . findFirst ( { container } ) ,
22
- [ tabster ] ,
21
+ ( container : HTMLElement ) => tabsterRef . current ?. focusable . findFirst ( { container } ) ,
22
+ [ tabsterRef ] ,
23
23
) ;
24
24
25
25
const findLastFocusable = React . useCallback (
26
- ( container : HTMLElement ) => tabster ?. focusable . findLast ( { container } ) ,
27
- [ tabster ] ,
26
+ ( container : HTMLElement ) => tabsterRef . current ?. focusable . findLast ( { container } ) ,
27
+ [ tabsterRef ] ,
28
28
) ;
29
29
30
30
const findNextFocusable = React . useCallback (
31
31
( currentElement : HTMLElement , options : Pick < Partial < TabsterTypes . FindNextProps > , 'container' > = { } ) => {
32
- if ( ! tabster || ! targetDocument ) {
32
+ if ( ! tabsterRef . current || ! targetDocument ) {
33
33
return null ;
34
34
}
35
35
36
36
const { container = targetDocument . body } = options ;
37
37
38
- return tabster . focusable . findNext ( { currentElement, container } ) ;
38
+ return tabsterRef . current . focusable . findNext ( { currentElement, container } ) ;
39
39
} ,
40
- [ tabster , targetDocument ] ,
40
+ [ tabsterRef , targetDocument ] ,
41
41
) ;
42
42
43
43
const findPrevFocusable = React . useCallback (
44
44
( currentElement : HTMLElement , options : Pick < Partial < TabsterTypes . FindNextProps > , 'container' > = { } ) => {
45
- if ( ! tabster || ! targetDocument ) {
45
+ if ( ! tabsterRef . current || ! targetDocument ) {
46
46
return null ;
47
47
}
48
48
49
49
const { container = targetDocument . body } = options ;
50
50
51
- return tabster . focusable . findPrev ( { currentElement, container } ) ;
51
+ return tabsterRef . current . focusable . findPrev ( { currentElement, container } ) ;
52
52
} ,
53
- [ tabster , targetDocument ] ,
53
+ [ tabsterRef , targetDocument ] ,
54
54
) ;
55
55
56
56
return {
0 commit comments