react-spatial-navigation icon indicating copy to clipboard operation
react-spatial-navigation copied to clipboard

A way to find the currently focused item.

Open stuartflanagan opened this issue 6 years ago • 5 comments

Is your feature request related to a problem? Please describe. A way to find the currently focused item. This may already be available I am just not sure of the API to surface it sorry.

Describe the solution you'd like SpatialNavigation.currentlyFocusedItem()

I am trying to find a way to get the currently focused item to return to after certain warnings or actions.

Is there a way to retrieve the current withFocusable item that is in focus from the library?

stuartflanagan avatar Nov 12 '19 00:11 stuartflanagan

Any updates on how this can be achieved from the API would be very helpful

stuartflanagan avatar Nov 25 '19 22:11 stuartflanagan

Hi! This is on our radar, we also had some use cases where we need to know the focus key of currently focused item (or other information about it). So I hope it will be added soon.

asgvard avatar Nov 25 '19 22:11 asgvard

Thank you for responding! I will keep an eye out.

stuartflanagan avatar Nov 25 '19 22:11 stuartflanagan

Hi, any news on this topic? Thanks

MarcoFiusco avatar Oct 03 '20 07:10 MarcoFiusco

Hi,

Sorry, nothing new so far, as we still didn't have real use case where we need to know the currently focused item. Usually the item itself getting focused flag is more than enough. Or in case of parent items - hasFocusedChild. But feel free to make a PR. There is similar PR #52 however it implies exporting the whole instance of SpatialNavigation, which could be a bit dangerous since you can basically execute any method from it manually as there are no "private" methods then. So perhaps the better solution would be to export simple method that will get currently focused item, together with the global methods exported from the lib like initNavigation etc. from index.js.

asgvard avatar Oct 03 '20 17:10 asgvard