Focusable container agnostic methods available as top level exports + doesFocusableExist #94
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
!! Breaking change !!
To use
setFocus
,getCurrentFocusKey
,navigateByDirection
,pause
,resume
,updateAllLayouts
methods it is required to create new focusable component. Such component is usually useless and gives nothing to the overall navigation. Moreover, react component has few more state variables defined that just take resources.Mentioned methods are working fine outside the context of the Focusable Container, so it's better to have them available as top level exports.
If you would like to keep backward compatibility,
useFocusableHook
can still return them, but I think cleaner way is to just move those methods and bump proper version number.PR adds also one more, very handy method:
doesFocusableExist
. Sometimes, when restoring screen state, it's crucial to know if element we want to focus still exists or not. Such check allows avoiding unintentional focus loss.