@@ -112,10 +112,10 @@ It is useful when you first open the page, or i.e. when your modal Popup gets mo
112112
113113``` jsx
114114import React , { useEffect } from ' react' ;
115- import { useFocusable , FocusContext } from ' @noriginmedia/norigin-spatial-navigation' ;
115+ import { useFocusable , FocusContext , setFocus } from ' @noriginmedia/norigin-spatial-navigation' ;
116116
117117function Popup () {
118- const { ref , focusKey , focusSelf , setFocus } = useFocusable ();
118+ const { ref , focusKey , focusSelf } = useFocusable ();
119119
120120 // Focusing self will focus the Popup, which will pass the focus down to the first Child (ButtonPrimary)
121121 // Alternatively you can manually focus any other component by its 'focusKey'
@@ -297,6 +297,31 @@ setThrottle({
297297### ` destroy `
298298Resets all the settings and the storage of focusable components. Disables the navigation service.
299299
300+ ### ` doesFocusableExist ` (function) ` (focusKey: string) => boolean `
301+ Returns ` true ` if Focusable Container with given ` focusKey ` is created, ` false ` otherwise.
302+
303+ ### ` setFocus ` (function) ` (focusKey: string) => void `
304+ Method to manually set the focus to a component providing its ` focusKey ` . If ` focusKey ` is not provided or
305+ is equal to ` ROOT_FOCUS_KEY ` , an attempt of focusing one of the force-focusable components is made.
306+ See ` useFocusable ` hook [ ` forceFocus ` ] ( #forcefocus-default-false ) parameter for more details.
307+
308+ ### ` getCurrentFocusKey ` (function) ` () => string `
309+ Returns the currently focused component's focus key.
310+
311+ ### ` navigateByDirection ` (function) ` (direction: string, focusDetails: FocusDetails) => void `
312+ Method to manually navigation to a certain direction. I.e. you can assign a mouse-wheel to navigate Up and Down.
313+ Also useful when you have some "Arrow-like" UI in the app that is meant to navigate in certain direction when pressed
314+ with the mouse or a "magic remote" on some TVs.
315+
316+ ### ` pause ` (function)
317+ Pauses all the key event handlers.
318+
319+ ### ` resume ` (function)
320+ Resumes all the key event handlers.
321+
322+ ### ` updateAllLayouts ` (function)
323+ Manually recalculate all the layouts. Rarely used.
324+
300325### ` useFocusable ` hook
301326This hook is the main link between the React component (its DOM element) and the navigation service.
302327It is used to register the component in the service, get its ` focusKey ` , ` focused ` state etc.
@@ -398,11 +423,6 @@ function Button() {
398423Method to set the focus on the current component. I.e. to set the focus to the Page (Container) when it is mounted, or
399424the Popup component when it is displayed.
400425
401- ##### ` setFocus ` (function) ` (focusKey: string) => void `
402- Method to manually set the focus to a component providing its ` focusKey ` . If ` focusKey ` is not provided or
403- is equal to ` ROOT_FOCUS_KEY ` , an attempt of focusing one of the force-focusable components is made.
404- See ` useFocusable ` hook [ ` forceFocus ` ] ( #forcefocus-default-false ) parameter for more details.
405-
406426##### ` focused ` (boolean)
407427Flag that indicates that the current component is focused.
408428
@@ -414,23 +434,6 @@ Only works when `trackChildren` is enabled!
414434String that contains the focus key for the component. It is either the same as ` focusKey ` passed to the hook params,
415435or an automatically generated one.
416436
417- #### ` getCurrentFocusKey ` (function) ` () => string `
418- Returns the currently focused component's focus key.
419-
420- ##### ` navigateByDirection ` (function) ` (direction: string, focusDetails: FocusDetails) => void `
421- Method to manually navigation to a certain direction. I.e. you can assign a mouse-wheel to navigate Up and Down.
422- Also useful when you have some "Arrow-like" UI in the app that is meant to navigate in certain direction when pressed
423- with the mouse or a "magic remote" on some TVs.
424-
425- ##### ` pause ` (function)
426- Pauses all the key event handlers.
427-
428- ##### ` resume ` (function)
429- Resumes all the key event handlers.
430-
431- ##### ` updateAllLayouts ` (function)
432- Manually recalculate all the layouts. Rarely used.
433-
434437### ` FocusContext ` (required for Focusable Containers)
435438Used to provide the ` focusKey ` of the current Focusable Container down the Tree to the next child level. [ See Example] ( #wrapping-leaf-components-with-a-focusable-container )
436439
0 commit comments