Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Focusable container agnostic methods available as top level exports + doesFocusableExist #94

Merged

Conversation

adrian-wozniak
Copy link
Contributor

@adrian-wozniak adrian-wozniak commented Aug 31, 2023

!! 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.

Copy link
Collaborator

@asgvard asgvard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a major release due to breaking changes, but of course makes sense, global methods should be imported from a global service, they are not linked to any specific focusable component

src/SpatialNavigation.ts Show resolved Hide resolved
@asgvard asgvard merged commit b78cdec into NoriginMedia:main Sep 11, 2023
@asgvard
Copy link
Collaborator

asgvard commented Sep 11, 2023

Done, thanks again for all the PRs! I will publish a new major release soon :)

@adrian-wozniak adrian-wozniak deleted the api-methods-as-top-level-exports branch September 28, 2023 11:26
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants